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.

Features:

DESCRIPTION FREE VERSION PRO VERSION
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
PRICE FREE 29 USD

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/automysqlbackup.sh http://www.grafxsoftware.com/download/backup-plesk/automysqlbackup.sh
chmod 700 /etc/cron.daily/automysqlbackup.sh

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 gfx_backup.sh 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/gfx_backup.sh http://www.grafxsoftware.com/download/backup-plesk/gfx_backup.sh
wget -O /etc/cron.weekly/execute_weekly_backup.sh http://www.grafxsoftware.com/download/backup-plesk/execute_weekly_backup.sh
chmod 700 /etc/cron.weekly/execute_weekly_backup.sh
chmod 700 /root/backup_script/gfx_backup.sh

Edit /root/backup_script/gfx_backup.sh and set (compulsory)

ROOTDIR="/root/backup_script/"
DIRS="/etc /home/backups/ /var/www/httpd/vhosts"
FTPD="/"
FTPU="USERNAME"
FTPP="PASSWORD"
FTPS="IP-OF-YOUR-SERVER"
EMAILID="YOUR-EMAIL-HERE"

After saving these settings, call the scipt as folows.

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

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

Order PRO version here.

Other faq items