Script to Automate FTP site Backup.

Based on my yesterday experimentations, I’ve code today a little script to automate the backup of several websites of mine. This script use lftp to mirror file from a remote host to your local machine. Then it create a bzip2 archive.

You can download the script here. To make it working, you need python on your system. To configure it, edit the ftpsite_list python list in the begining of the file.

5 thoughts on “Script to Automate FTP site Backup.

  1. Hey,
    I try to use your Python script to make a backup of my website. The site is on a UNIX based server while the backup should be taken place on a Windows pc.

    I added the first few lines of your script like this:

    FTP_USER = 'vierling'
    FTP_PASS = 'mexico7'
    FTP_SITE = 'home.casema.nl'
    FTP_PORT = '21'
    BACKUP_DIR = 'd:/temp/backup'
    
    ftpsite_list = [
      { 'title'     : "Web site 1"
      , 'user'      : FTP_USER
      , 'password'  : FTP_PASS
      , 'site'      : FTP_SITE
      , 'port'      : FTP_PORT
      , 'remote_dir': ''
      , 'local_dir' : 'test'
      },
    ]
    

    On my computer a created a directory d:\temp\backup.

    After running the script the following subdirs where created: D:\temp\backup\test\current but with nothing in it.

    What did I do wrong?

    Best regards,
    Gertjan

  2. Hi Gertjan !
    Thanks for you interest in my tiny scripts.

    About your problem: you do right. But actually, my script call some UNIX commands to do its job from the system where the script is launched. That’s why this script will not work on windows. Sorry, I wasn’t clear enough in my post.

    Why I use UNIX commands in my python script ? Because they are more reliable and able to get huge FTP site. Look my previous post “Bad FTP mirrors with fmirror or wget ? Use lftp !”.

    BTW, I think its possible to make my script system-independant by using some pure FTP python libs like:

    But before this happened, I have to do intensive tests with libs above to be sure they can handle huge FTP site (and this will take time: I have other projects to finish before going back to this script).

  3. How difficult would it be to make this script mirror -R TO a remote ftp server? (Reverse the backup)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.