Backup with duplicity
duplicity backs directories by producing encrypted tar-format volumes and uploading them to a remote or local file server. Because duplicity uses librsync, the incremental archives are space efficient and only record the parts of files that have changed since the last backup. Because duplicity uses GnuPG to encrypt and/or sign these archives, they will be safe from spying and/or modification by the server.
Duplicity can be installed in Debian / Ubuntu as simple as:
$ sudo aptitude install duplicity
But it not in the CentOS / RedHat default repositories, so you need to install from another source. This script will help in this installation process:
#!/bin/bash
#ARCH=i386
ARCH=x86_64
wget http://download.fedora.redhat.com/pub/epel/5/$ARCH/duplicity-0.6.14-1.el5.$ARCH.rpm
wget http://download.fedora.redhat.com/pub/epel/5/$ARCH/ncftp-3.2.2-1.el5.$ARCH.rpm
wget http://download.fedora.redhat.com/pub/epel/5/$ARCH/librsync-0.9.7-13.el5.$ARCH.rpm
wget http://download.fedora.redhat.com/pub/epel/5/$ARCH/python-GnuPGInterface-0.3.2-2.el5.noarch.rpm
wget http://download.fedora.redhat.com/pub/epel/5/$ARCH/python-boto-1.9b-6.el5.noarch.rpm
rpm -Uvh duplicity-0.6.14-1.el5.$ARCH.rpm ncftp-3.2.2-1.el5.$ARCH.rpm librsync-0.9.7-13.el5.$ARCH.rpm python-GnuPGInterface-0.3.2-2.el5.noarch.rpm python-boto-1.9b-6.el5.noarch.rpm
See also:
Remote backup with duplicity
<source lang="bash">
- !/bin/bash
-
- BEGIN CONFIG ##
HOST=$(uname -n) MYSQL_PASS="" OPENKM_HOME="/home/openkm" JBOSS_HOME="$OPENKM_HOME/jboss-4.2.3.GA" DATABASE_EXP="$OPENKM_HOME/db" BACKUP_DIR="ftp://user@ftp.domain.es/backup" export FTP_PASSWORD="WhateverPasswordYouSetUp"
- END CONFIG ##
if [ $(id -u) != 0 ]; then echo "You should run this script as root"; exit; fi
echo -e "### BEGIN: $(date +"%x %X") ###\n" rm -rf $DATABASE_EXP mkdir -p $DATABASE_EXP
- Stop JBoss
/etc/init.d/jboss stop
- Clean logs
echo "Clean JBoss temporal files." rm -rf $JBOSS_HOME/server/default/log rm -rf $JBOSS_HOME/server/default/tmp rm -rf $JBOSS_HOME/server/default/work
- Backup de MySQL
if [ -n "$MYSQL_PASS" ]; then
MYSQL_DBS=$(mysqlshow -h localhost -u root -p$MYSQL_PASS | awk '(NR > 2) && (/[a-zA-Z0-9]+[ ]+[|]/) && ($2 != "mysql") && ($2 != "test") && ($2 != "information_schema") { print $2 }');
for DB in $MYSQL_DBS ; do echo "* Backuping MySQL data from $DB..."; mysqldump -h localhost -u root -p$MYSQL_PASS $DB > $DATABASE_EXP/mysql_$DB.sql done echo "-------------------------------------";
fi
- Backup and purge old backups
duplicity remove-older-than 1Y --force $BACKUP_DIR/$HOST duplicity $OPENKM_HOME $BACKUP_DIR/$HOST unset FTP_PASSWORD
- Start JBoss
/etc/init.d/jboss start echo -e "\n### END: $(date +"%x %X") ###"
- Status
echo "================================="; duplicity collection-status $BACKUP_DIR/$HOST echo "================================="; <source>