MySQL Backup Script Creates a backup for all MySQL databases.
Cleanup script Removes the last n files from a directory listing.
MySQL Backup Cleanup Cleans old MySQL dumps.
Xen backup script creates a live snapshot for each virtual machine.
On the linux machines, check out the repository to the /opt
directoy.
cd /opt/
git clone https://github.com/MkrV/backuputils.git
mkdir /opt/backuputils/dumps
Ensure that the scripts can be executed
chmod +x /opt/backuputils/*.sh
Add a new cronjob to /etc/cron.d
:
# /etc/cron.d/zeyos-backuputils
# Updates the authorized_keys every day
0 0 * * * root /opt/backuputils/mysql-backupall.sh ~/dumps
0 0 * * * root /opt/backuputils/mysql-cleanupall.sh 5 /opt/backuputils/dumps
Preparation:
You should create a backup user that only has read priviledges.
mysql>CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mytemporarypassword';
mysql>GRANT SELECT ON *.* TO 'jeffrey'@'localhost' IDENTIFIED BY 'mytemporarypassword';
if you will run the script not as root user, then change the USER in mysql-backupall.sh:
USER=
root
USER=jeffrey
set the PASSWORD value, for example:
PASSWORD=mytemporarypassword
do not copy the example, set your own PASSWORD
Usage:
shell>mysql-backupall.sh <DIRECTORY>
Example:
/opt/backuputils/mysql-backupall.sh /opt/backuputils/dumps
You could use mysql-cleanupall.sh script if you want to keep equal count of dumps of each databases.
The mysql-cleanupall.sh script call internally the cleanup.sh.
Usage:
shell>mysql-cleanupall.sh <LIMIT> <DIRECTORY>
Example:
/opt/backuputils/mysql-cleanupall.sh 5 /opt/backuputils/dumps
You could use cleanup.sh script if you want to decrease the count of dumps of the selected database.
The cleanup.sh used internally in the mysql-cleanupall.sh.
Usage:
shell>cleanup.sh <LIMIT> <BASENAME> <DIRECTORY>
Example:
/opt/backuputils/cleanup.sh 5 mydb.sql /opt/backuputils/dumps
Usage:
shell>xen-backupall.sh <DIRECTORY>
Copyright © 2016 ZeyOS, Inc.
This work is licensed under the Massachusetts Institute of Technology License (MIT).