Site icon GetPageSpeed

Magento 1.x backup script

Backups are important. The following backup script will allow you to backup both Magento 1.x files and database. It doesn’t require hard coding database details. The script is smart enough to extract those details from Magento configuration files. This is quite flexible.

Another nice feature of the script is having the backups running at both low CPU and IO priority. Your store will keep running as smoothly as always. For that, we make use of ionice and nice utilities found on all major Linux distros by default.

Here is how to setup backups in cron:

@daily /bin/bash /usr/local/bin/backup-magento.sh /var/www/html /var/backups/daily 3
@weekly /bin/bash /usr/local/bin/backup-magento.sh /var/www/html /var/backups/daily 21
@monthly /bin/bash /usr/local/bin/backup-magento.sh /var/www/html /var/backups/daily 60

Now you have 3 slots of backups with difference frequency: one backup will 24hrs freshness, one for weekly, and one for monthly. The previous backups will be automatically cleaned every time a slot is run.

Exit mobile version