Difference between revisions of "Backup with duplicity"

From OpenKM Documentation
Jump to: navigation, search
m (Remote backup with duplicity)
m (Remote backup with duplicity)
Line 53: Line 53:
 
rm -rf $JBOSS_HOME/server/default/tmp
 
rm -rf $JBOSS_HOME/server/default/tmp
 
rm -rf $JBOSS_HOME/server/default/work
 
rm -rf $JBOSS_HOME/server/default/work
 +
rm -rf $JBOSS_HOME/server/default/data/wsdl
  
 
# Backup de MySQL
 
# Backup de MySQL

Revision as of 10:20, 31 October 2011

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">

  1. !/bin/bash
    1. 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"

    1. 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

  1. Stop JBoss

/etc/init.d/jboss stop

  1. 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 rm -rf $JBOSS_HOME/server/default/data/wsdl

  1. 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

  1. Backup and purge old backups

duplicity remove-older-than 1Y --force $BACKUP_DIR/$HOST duplicity --no-encryption $OPENKM_HOME $BACKUP_DIR/$HOST

  1. Start JBoss

/etc/init.d/jboss start echo -e "\n### END: $(date +"%x %X") ###"

  1. Status

echo "================================="; duplicity collection-status $BACKUP_DIR/$HOST unset FTP_PASSWORD echo "================================="; <source>