BackupT2BCloud: Difference between revisions
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
password=secret | password=secret | ||
</pre> | </pre> | ||
Here is the script that does a dump into a file : | |||
<pre> | |||
#!/bin/bash | |||
# Create the backup directory if it doesn't exist | |||
BACKUPDIR=/var/lib/one/one_mysql_db_backups | |||
mkdir -p $BACKUPDIR | |||
# Remove backups older than 7 days | |||
find $BACKUPDIR -name 'one_db_mysqldump*' -mtime +7 -exec rm -f {} \; | |||
# Make a dump of the db to a file in BACKUPDIR | |||
DATE=`date +'%d-%m-%y_%H:%M:%S'` | |||
FILENAME=$BACKUPDIR"/one_db_mysqldump_$DATE" | |||
mysqldump opennebula > $FILENAME | |||
</pre> | |||
Dumps older than 7 days are removed. |
Revision as of 14:11, 30 August 2016
Backup of VMs
The whole /var/lib/one directory is mounted from the volta fileserver, and regular scheduled snapshots are done automatically to tesla. You can access to these snapshots going through /var/lib/one/.zfs.
Backup of the OpenNebula database
The OpenNebula database being located in /var/lib/mysql, it is not backed up with the ZFS snapshots described in the previous section. That's why we have created a cron task to automatically do a regular dump of the mysql database into the /var/lib/one directory.
To avoid having to specify the user and password in the mysqldump command, we have created the file ~/.my.cnf with the following content :
[mysqldump] user=mysqluser password=secret
Here is the script that does a dump into a file :
#!/bin/bash # Create the backup directory if it doesn't exist BACKUPDIR=/var/lib/one/one_mysql_db_backups mkdir -p $BACKUPDIR # Remove backups older than 7 days find $BACKUPDIR -name 'one_db_mysqldump*' -mtime +7 -exec rm -f {} \; # Make a dump of the db to a file in BACKUPDIR DATE=`date +'%d-%m-%y_%H:%M:%S'` FILENAME=$BACKUPDIR"/one_db_mysqldump_$DATE" mysqldump opennebula > $FILENAME
Dumps older than 7 days are removed.