Learn about Centmin Mod LEMP Stack today
Register Now

Auto Database Backup Script 1.0

Export and Upload your Database to Offsite location with Cron

  1. Matt
    These are 2 scripts I wrote to automate the nightly backup of my databases and upload them to a remote location via FTP.

    There is a bash script that you call from cron at a time of your choice. This uses mysqldump to make a copy of your database, compress is using pbzip2 (adjust to bzip2 or gzip if you don't have pbzip2 installed), and then calls the upload.pl script to upload the file via FTP to the remote site (keeping 5 rolling days worth of backups).

    For my own use, I backup several databases each night, so the perl script is creating an array of file names, and using a foreach loop. If you only have a single database to back up, you can remove the foreach loop, and set the array to be a single variable.

    Feel free to adjust to suite your own needs, and I'll try and provide assistance as and where needed.

    dbbackup.PNG

    upload.PNG

Recent Reviews

  1. vultranet
    vultranet
    5/5,
    Version: 1.0
    CENTMINMOD THE MOST POWERFULL STACK THAT I TRIED