Wednesday, 30 November 2016

Magento site backup bash script

This is a simple bash script for backing up the Magento site code base .

Note:
 1) Currently the media and var folders are not excluding.
     Will update once they work fine!

2) To run the below bash script:

     In Ubuntu terminal:  . ./scriptname.sh

#!/bin/bash
#START
#Code Backup
TIME=$(date +'%Y-%m-%d_%H-%M')
FILENAME=myFile-$TIME.tar.gz
SRCDIR="/var/www/html/ProjectFolder"
DESDIR="/home/backups/files"
tar cpzfP $DESDIR/$FILENAME $SRCDIR --exclude "/var/www/html/ProjectFolder/media/"  --exclude "/var/www/html/ProjectFolder/var/"  --exclude "/var/www/html/ProjectFolder/SAP/" --exclude "/var/www/html/ProjectFolder/magmi/"
#To backup only the media directory change
#tar -zcf backup-YYYY-MM-DD-HH-MM.tar.gz public_html/media/
#END