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.
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\currentbut with nothing in it.What did I do wrong?
Best regards,
Gertjan
By the way, above mentioned username and password are fake.
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).
How difficult would it be to make this script mirror -R TO a remote ftp server? (Reverse the backup)
This script works just fine for me under Ubuntu Linux. I installed ftplib3, but I’m not even sure it was necessary.