Website Backup Script: MySQL dumps and SSH supported.

Three months after the last version, here is a big update of my backup scripts for websites. The script was greatly improved and among new features, the most important is the support of backups over SSH and backups of MySQL databases.

Change log:

  • Each item of the user’s backup_list must specify the type property (FTP, FTPs, SSH, MySQLdump or MySQLdump+ssh).
  • The property previously known as site is now host.
  • File system structure changed: /ftp-mirror folders renamed to /mirror.
  • Add SSH backups.
  • The script is able to detect if a SSH connexion can be initiated without a password. This was designed for people who don’t like the idea of storing clear password in the script. Thanks to this feature, you can benefit public key authentication from OpenSSH.
  • Use of rsync whenever it’s possible for bandwidth efficiency.
  • FTP and FTPs (aka FTP over SSL) are now handled separately: this supress the default fall-back to FTP if FTPs is not supported by the remote server. This is safer as it doesn’t let lftp make the decision for you to send your clear password on the net.
  • All ports are optionnal, no need to specify it you use default ports.
  • Add MySQL backups thanks to mysqldump.
  • Two mode of MySQL backups: through SSH or direct connection to server.
  • A particular database to backup can be specified. Else, all databases are backed up.
  • Much more detailed logs that include external command’s output.
  • Auto-detect the existence of required external tools and commands at launch.
  • Use pexpect lib to simulate user password input.
  • Run all external commands in english for consistency.
  • Check that the script is running in a posix environnement.
  • Fix bug related to directory creation.

If you were using a previous version of my backup script and want to use this updated version, take care of changes, especially the ones describes in the first 3 items of the change log above.

7 Responses to “Website Backup Script: MySQL dumps and SSH supported.”


  1. 1 Daniel

    Do you know the program duplicity?
    With duplicity you can save your data encrypted. I use this when I want to save my data on a ftp-server.

  2. 2 kev

    Do you know the program duplicity?

    Hi Daniel. Yes, I know duplicity: it was created by the same author as rdiff-backup. Currently I don’t need it because all my backups are saved on machines within a LAN protected by a firewall. My backup server can’t be reached by Internet so I don’t need an extra level of security (read complexity).

  3. 3 Matthew

    Very Very Very nice piece of code.. Thank you.

    I have a feature request. I want to use your script to backup a couple dozen sites. It would be nice to have the configurations on an external file or pulled from a database. I hate to modify the main scripts when i add a new site. Perhaps a different config file per site.

  4. 4 kev

    It would be nice to have the configurations on an external file or pulled from a database.

    Thanks Matthew for this suggestion !

    I will consider to add this feature for the next release.

    But currently I’m not focused on this script, so don’t expect to have a new release any time soon. Please keep an eye on this blog via the RSS feed to be informed about new updates !

  5. 5 dan

    Whenever I try the mysql+ssh method, I keep getting prompted for the password. I looked at the code, and it looks like it is missing the function to send the password for this method (file backup over SSH works fine). Is this expected behavior, or am I doing something wrong?

  6. 6 mykey

    hi

    I really like this script - or rather - the features it is supposed to deliver. I am running sshd on a non standard port and try to use the passwordless login variant - it works well dumping the databases just using 'xxx.xxx.xxx.xxx -p 22222' for the host address, but when I try the same thing backing up my htdocs directory, rsync fails with the following error:

     INFO - rsync output:
            building file list ...
            rsync: link_stat "/root/mykey@xxx.xxx.xxx.xxx" failed: No such file or directory (2)
            rsync: link_stat "/root/22222:/var/www/htdocs" failed: No such file or directory (2)
            0 files to consider
    

    If you can supply a hint on how to avoid that I would be very pleased - please email me if you can see a solution.
    Thanks anyway for the nice script.

  1. 1 Website Backup Script: bug fix release at Coolkevmen

Leave a Reply