Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




Backup To Other Computers

Consider the situation of a collection of Debian boxes with no backup facilities as such, but there is an accessible machine with a proper backup regime. Access to the backed up machine is via ssh. The backup can be performed using a backup script which you create in /etc/cron.daily so that it will be executed each day (by default, 6:25am). The contents of the script are:

  # Script for /etc/cron.daily

  DEST="[email protected]:backup/$(/bin/hostname)"
  OPTS="--rsh=ssh --cvs-exclude --archive --compress "
  OPTS=${OPTS}"--delete --delete-excluded --verbose"

  echo "===================================================" >> ${LOGFILE}
  date >> ${LOGFILE}
  echo "$RSYNC $OPTS --include-from ${INCFILE} / ${DEST}" >> ${LOGFILE}

  $RSYNC ${TESTING} $OPTS --include-from ${INCFILE} / ${DEST} >> ${LOGFILE}

  date >> ${LOGFILE}
  echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >> ${LOGFILE}

The file /etc/backup.include might contain:

  # Identify specific file types to exclude
  - *.mp3
  - *.rpm
  - *.deb
  - *.wav
  - *.avi
  - *.mov
  - *.temp
  - *.tmp
  - *.cdr
  # Exclude paths that contain
  - .thumbnails
  - .xvpics
  - cache
  - skins
  - thumbnails
  # Now specify specific trees to back up
  + /etc
  + /home
  + /root
  + /usr/local
  + /var/mail
  + /var/backups
  # And exclude everything else
  - /*

Since this is using ssh (OpenSSH, ssh protocol 2) and it is a cron job (i.e., you can not supply a password or passphrase), create a ssh public key for adding to [email protected]'s authorized keys file:

  modena# ssh-keygen -t dsa -N ""

  Generating public/private dsa key pair. 
  Enter file in which to save the key (/root/.ssh/id_dsa): 
  Your identification has been saved in /root/.ssh/id_dsa. 
  Your public key has been saved in /root/.ssh/ 
  The key fingerprint is:
  ce:b3:e5:82:ab:72:3d:50:2e:96:65:e0:15:a3:4e:de [email protected]

  modena# scp .ssh/ [email protected]:.ssh/authorized_keys.n
  modena# ssh [email protected]

  caravan$ cd .ssh
  caravan$ cat authorized_keys.n >> authorized_keys
  caravan$ rm authorized_keys.n
  caravan$ exit

Then the ssh connections will go straight through to [email protected] without the need to supply a password (or passphrase).

Copyright © 1995-2006 [email protected]

  Published under the terms fo the GNU General Public License Design by Interspire