Automated Remote FTP Backup shell script

Date: 26 October 2008
Source: GraFX

Saving the data from the server may be a problem, especially if you forget about it. Unfortunately the solution provided by PLESK is not always the best one, thus we have tried to come up with a backup alternative.

The steps we recommend are :

  • Setting/Saving the database daily, with upload on a weekly FTP server
  • Setting/Saving the data on a weekly basis and uploading on a FTP server

When you take a dedicated server, usually the company providing it, alocates a FTP space as well for backup for an extra cost or even included in the cost of the server. This space may be accessed only from their internal network, offering more security for protecting the data. Let's see what we need to do in this direction.


Will dump daily the databases (based on AutoMySQLBackup shell script) YES YES
Will arhive directories what you define (we use usually /etc/ and /var/www/vhosts/*/). YES YES
Have GPG encryption. (switch ON/OFF) YES YES
Will upload to remote FTP, weekly (or can daily) YES YES
Will send mail to ADMIN about job. YES YES
Will report from remote FTP all files for disk space usage and will also delete files from there. YES YES
Can restore file from Remote FTP. YES YES
Split large files into 1GB. YES -
Can archive in multiple files (one file for each domain) NO YES
Can exclude files (avi, mov, etc) NO YES
Archive MONDAY-SUNDAY with excluded files, SATURDAY full backup NO YES

Setting/Saving the database on a daily basis (locally)

Downoad the automysqlbackup script from our server, modified in such a way that it creates separate folders for each saving. Thus you may search for a certain database very easily. Copy it on the dedicated server, in the /etc/cron.daily/, execute

wget -O /etc/cron.daily/
chmod 700 /etc/cron.daily/

folder and change the execution rights.

Edit the file and modify (or not) BACKUPDIR="/home/backups" (if you maintain this setting, you have to create the folder), MAILADDR="YOUR-EMAIL-HERE", and you may leave the rest of the information unmodified.

Setting/Saving the data on a weekly basis and uploading on a FTP server

Download the script and upload it to your server (PRO version is not available for free download, only after purchase).

Execute the following commands.

mkdir /home/backups
mkdir /root/backup_script
cd /root/backup_script
wget -O /root/backup_script/
wget -O /etc/cron.weekly/
chmod 700 /etc/cron.weekly/
chmod 700 /root/backup_script/

Edit /root/backup_script/ and set (compulsory)

DIRS="/etc /home/backups/ /var/www/httpd/vhosts"

After saving these settings, call the scipt as folows.

  • sh /root/backup_script/ --backup
  • sh /root/backup_script/ --restore
  • sh /root/backup_script/ --report
  • sh /root/backup_script/ --help

Any bug/ideea shuld be sent via our contact form.

Order PRO version here.

Other faq items