Hi all,
I had written a simple bash script, which is still in very basic shape. I planned to release it in a version cycle. The basic goal is to create backup of mentioned directories. I am working on it to improve it and release further revisions of it. The script is capable of:
1- Backup the mentioned directory(in this case www) with tar.gz compression.
2- Backup MySQL mentioned database with compression.
There are just few changes you need to do, because its the early version so i need to improve it more and more. Also you can setup it up under cron to run it on specified time and create backup automatically. I will guide here step by step what changes need to make and how to setup it under cron.
cd /Documents/
In the above line, one need to change the directory where the backup files will be stored. Can create directory in home and give the path here.
INPUTDIR=”/Assignments/”
Change the above to your www directory, which maybe in /var/ or in /srv/.
mysqldump -uroot -ppassword –opt database_name > database_backup_$(date +%Y%m%d).sql
In the above line, you need to change the database username, password and database name.
And you are almost done till here.
Now lets automate this script in cron to create backup of the selected directories at midnight every day.
0 0 * * * sh /home/user/backup_0.1.sh
For more about cron… here.