Managing a server, even very small, means the creation of backup procedures to protect our data from possible lost and fault.
This small bash script creates a backup of a specific MySQL database and gzips.The system I've used is to create a bash for each mysql database that I host and run it through cronjob.
The database zipped then I'll make it accessible by FTP to download it from a local server to a set time. In order to have a copy of everything always at hand. Below is the bash script that I use in the first part of my backup procedures.
# Back Up Mysql & GZIP #!/bin/bash FILE=/path/del/backup/sqlfile.sql FILEBK=/path/del/backup/sqlfile.sql.gz # DB Credentials NAME=root PASS=password DB=databasename // Remove old BK File rm $FILEBK echo "Content-type: text/plain" echo echo "Tried to export file: "$FILE # MySQl Dump mysqldump --quote-names -u $NAME --password=$PASS $DB > $FILE # GZIP gzip -v $FILE
Of course you can create a backup rotation or adding dates of the folders or the system date to the file name.
For any questions or concerns please leave a comment.