1

My backups are stored on remote FTP server. I'm looking for a universal way to clean-up the FTP directory using bash or python.

Any help would be appreciated.

Edited: I have only FTP access to the server.

I need to cleanup the directory via remotely logging in via FTP

0

1 Answer 1

2

You need to provide more information to get meaningful help.

At least:

  • How do you access the server? Do you have a direct (SSH or similar) shell connection, or are you limited to FTP? Can you install cron entries on the server?
  • How do you want to purge? Everything older than X days? When exceeding a certain size limit (dangerous)? ...?

That said, some pointers:

  • If you can run your script locally (via SSH from somewhere else, or via crontab, things will be easier). Then you can just write a script that deletes locally based on your criteria. You might even get away with standard software, e.g. using logrotate (standard Linux utiliy) to rotate & delete old backups.
  • If you must go through FTP, you can use some helper library. Python has ftplib to use FTP from Python. Even better, mount the FTP server as a local dir using some mechanism like FUSE / CurlFtpFs.
  • You might want to consider switching to some more secure mechanism like SFTP or FTP-SSL for server access. These would also be somewhat easier to script.
1
  • Thanks for questions. I am limited only to FTP. Regarding purge: after clean-up should remain only last X backups
    – Deem3n
    Nov 9, 2009 at 12:59

Not the answer you're looking for? Browse other questions tagged .