Uncategorized

Automated Remote FTP Backup Shell Script

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, allocates 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:

  • Will dump daily the databases (based on AutoMySQLBackup shell script)
  • Will archive directories what you define (we use usually /etc/ and /var/www/vhosts/*/).
  • Have GPG encryption. (switch ON/OFF)
  • Will upload to remote FTP, weekly (or can daily)
  • Will send mail to ADMIN about job.
  • Will report from remote FTP all files for disk space usage and will also delete files from there.
  • Can restore file from Remote FTP.
  • Split large files into 1GB.
  • More smaller settings.

Setting/Saving the database on a daily basis (locally)
Download 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.

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 script as follows.

  • 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/idea should be sent via our website

Previous ArticleNext Article

Leave a Reply

Your email address will not be published. Required fields are marked *