Simple bash script to backup database and web server directory - ezi bakup
I wrote this script long time ago and released its 1st version v0.1 with very initial setup in mind. After that i haven’t got time to look into the code and enhance it further.
But today i am going to announce the 2nd version v0.2 with new features plus easy to setup params file. Detailed error description are added to the code for better output.
A separate params.ini file to change the settings, so it will be not needed to touch the code if you are not familiar with it. Just setup the params.ini file and you are good to go.
As usual it will backup the database and directory you want it to backup for you in your desired location(local system). Even can run it under cron to create backup for you let’s say once a day or a week, that depends on your needs.
I will explain the params.ini file in details so you get an idea, how it will work. The archive will include readme.txt, params.ini, ezi_bakup.sh
files. readme.txt will contain some basic setup and details about the script. params.ini will contain the settings and ezi_bakup.sh
is the meat which will do what you tell it via params.ini.
How to use(params.ini):
bkdrbool=FALSE
dbbool=TRUE
dbusername=root
dbpassword=
dbname=test
stgdir=/backup/
bakdir=/var/www/test_project
Line 1: set to true if want to backup web server or any dir, TRUE = create, FALSE = skip
Line 2: set to true for database backup, TRUE = create, FALSE = skip
Line 3,4: Database Username and password
Line 5: Database Name
Line 6: Storage/backup directory, where you want to backup your files
Line 7: Directory to create backup of
Cron sample setup:
This will run the script every day at 11PM with a log file created to output log events. Please change the path to the script.
0 23 * * * /backup/bash/ezi_bakup.sh >> /backup/bash/cron.log 2>&1
Updates:
- Future updates will be directly pushed to the repository.
- Repository: https://gitlab.com/mmarif4u/bash-backup-script
Download:
- Clone the repository. OR
- Download from master branch.
Feel free to report bugs here.