[GLLUG] backing it up

Scott Harrison harris41 at msu.edu
Tue Dec 21 11:03:24 EST 2004


> What software / scripts / etc. do you use to keep your documents backed 
> up and where do you back them up to.

I would recommend doing at least something like #2
(shown below).  Before setting up any backup system,
first think twice, and run a command like:
"cp -pRd working_directory/ backup_directory/".


1.  For continually changing files that are plaintext, I use
     subversion (http://subversion.tigris.org/).  Subversion
     also is handy for the occasional graphics file (gif, jpg, etc).
     It works okay with big binaries (*.doc files, etc), but I do
     not find much benefit there.


2.  rsync.  Here is an example template script (see below).
     (I'd be curious to hear recommended tweaks to any
      of this from others):


Regards,
Scott


#!/bin/sh

# /etc/cron.daily/mysql_backup
# Backup MySQL databases

# Originally inspired by http://www.zope.org/Members/jrush/howto_rsync_zope
# Scott Harrison 2004

# Two examples are shown below: 1) backing up "in situ" on the same
# computer, and 2) backing up from a remote computer.

# NOTE!  For backing up a remote server,
# to make "ssh" work in a transparent fashion (so that you
# are not password-prompted for each individual file), it is
# recommended that a RSA authentication mechanism be setup between
# the remote computer and the backup computer
# For more information, see
# http://www.defcon1.org/html/body_rsa-ssh.html
# (Examples of commands to type:
#  On local: ssh-keygen -t rsa
#  On local: scp ~/.ssh/id_rsa.pub 
somepoweruser at remote.computer.somewhere:/tmp/.
#  On remote: cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys2
# )
# Proper configuration of ssh_config and sshd_config (especially
# sshd_config on the remote server machine) may also be
# necessary (i.e. "RSAAuthentication yes") but most likely the
# defaults already support all this.

#
# rsync arguments:
# -q       ::= Quiet operation, for cron logs
# -u       ::= Update only, don't overwrite newer files
# -t       ::= Preserve file timestamps
# -p       ::= Preserve file permissions
# -o       ::= Preserve file owner
# -g       ::= Preserve file group
# -z       ::= Compress during transfer
# -e ssh   ::= Use the ssh utility to secure the link

SERVERNAME="another.server.com"

# Backup select mysql databases (LOCAL BACKUP SERVER)
#
ARCHTOP="/archive/mysql_local/"
DOW=`date +%A`
ARCHDIR="${ARCHTOP}${DOW}"
#
# Insure Our Day-of-Week Directory Exists
[ -d ${ARCHDIR} ] || mkdir -p ${ARCHDIR} || {
     echo "Could Not Create Day-of-Week Directory: ${ARCHDIR}" ; exit 1
}
#
# NOTE! "somedatabasename" and "myprojectdb" are included as example names,
# you want to replace these names (and the filesystem paths) with
# whatever directories you are trying to backup
/usr/bin/rsync -q -r -u -t -p -o -g /var/lib/mysql/somedatabasename 
${ARCHDIR}
/usr/bin/rsync -q -r -u -t -p -o -g /var/lib/mysql/myprojectdb ${ARCHDIR}
/usr/bin/rsync -q -r -u -t -p -o -g /var/lib/mysql/mysql ${ARCHDIR}
chmod -R a+rx ${ARCHDIR}
#
rm -f ${ARCHTOP}Current
ln -sf ${ARCHDIR} ${ARCHTOP}Current

# Backup select mysql databases (e.g. another.server.com)
#
#
# NOTE! you probably want to replace "ANOTHERSERVER" with a more
# meaningful string (for the ARCHTOP variable below)
ARCHTOP="/archive/ANOTHERSERVER_mysql/"
DOW=`date +%A`
ARCHDIR="${ARCHTOP}${DOW}"
#
# Insure Our Day-of-Week Directory Exists
[ -d ${ARCHDIR} ] || mkdir -p ${ARCHDIR} || {
     echo "Could Not Create Day-of-Week Directory: ${ARCHDIR}" ; exit 1
}
#
/usr/bin/rsync -q -u -t -r --rsh="ssh -l adminusername" 
adminusername@${SERVERNAME}::mysql/var/db/mysql/somedatabasename ${ARCHDIR}
/usr/bin/rsync -q -u -t -r --rsh="ssh -l adminusername" 
adminusername@${SERVERNAME}::mysql/var/db/mysql/myprojectdb ${ARCHDIR}
/usr/bin/rsync -q -u -t -r --rsh="ssh -l adminusername" 
adminusername@${SERVERNAME}::mysql/var/db/mysql/mysql ${ARCHDIR}
chmod -R a+rx ${ARCHDIR}
#
rm -f ${ARCHTOP}Current
ln -sf ${ARCHDIR} ${ARCHTOP}Current
#

exit 0


More information about the linux-user mailing list