http://www.Linux-Backup.net


Backup Issues

Backup Media

Backup Strategy

Copying Directories/Files

[Un]Deleting Directories/Files

Backup Failure Modes

Full/Incremental Backups

Example Backup Commands

Backup Programs/Scripts



1U Rackmount Chassis

Custom-Chassis.com

Linux-1U.net

1U-ITX.net


ITX-Blades.net


Small PC cases

Mini-Box.net

Wrap-Box.net

Wrap-OS.net


Wan-Sim.net



Linux-Consulting.com

Linux-CAE.net

Linux-Sec.net

Linux-Boot.net

Linux-Backup.net

Linux-Wireless.org

Linux-Office.net

Linux-Video.net

Linux-Jobs.net

Linux-Diff.net

1U-Raid5.net


Spam Reporting



Free Linux CDs

ISO9660.org

Distro-CD.org

Patch-CD.org



Linux is a registered trademark of
Linus Torvalds

More Linux Legalese


Example Backup/Restore Commands

  • NEVER automount your backup directories
    • the infamous "rm -rf /" will erase your automounted backups too

  • Always mount the backup directory before performing backups
  • Always unmount the backup directory when done performing backups

  • Prune your backups of un-necessary files from being backed up
    • tar --exclude /tmp --exclude /proc ...
    • egrep ".netscape/cache| *.o | *.swp | *~ | ..."

  • Be sure that the backup files is NOT group/world writable/readable
    • It'd contain confidential data, passwds etc

    • chown root /Backup_Dir/Date.x.tgz
    • chgrp backup /Backup_Dir/Date.x.tgz
    • chmod 440 /Backup_Dir/Date.x.tgz

    • encrypt your backup files if you are really paranoid about your passwd files


Example Backup Commands
  • Creating datestamps for file names
    • date '+%Y%m%d'
        Ouputs 20020615 for June 15, 2002

    • date '+%Y.%m.%d'
        Ouputs 2002.06.15 for June 15, 2002

    www.thing.dyndns.org bash examples

  • dd -- copying partitions, mirror'd partitions
    • mounting and unmounting is NOT needed in this case
    • dd if=/dev/hda1 of=/dev/hdb1 bs=1024

  • Simplified tar --newer Incremental Backup example
    • LastBackupTime = `cat /Backup_Dir/Last.txt`
    • tar zcvf --newer $LastBackupTime /Backup_Dir/Date.x.tgz $DIRS
    • echo "Date" > /Backup_Dir/Last.txt

  • Simplified find | tar Incremental Backup example
    • Cnt = `cat /Backup_Dir/Last.txt`
    • find $DIRS -mtime -$Cnt -print | tar zcvf /Backup_Dir/Date.$Cnt.tgz -T -
    • echo "$Cnt +1" > /Backup_Dir/Last.txt

  • Simplified dump | restore Backup example

  • Simplified cpio Backup example
    • find /home -xdev | cpio -pm /mnt/backup


Securely Copying the Backup File to the Remote Backup Servers
  • Simplified rsync - ssh example
    • rsync -e ssh -av raffi@BackupServer.your_domain.com::/home/Backup/xfer/* /destination/xfer

    • rsync -avz --delete HomeServer::/home/* /Backup/destination

Finding Files to Restore from Backups
  • Simplified find a file in the backups
    • grep "File_2_Find.txt" /Backup_Dir/*.log

Restore Example Restore Commands
  • If you have to restore lots of lost data from backups, something else is wrong with your computer usage policy and proceedures and hardware choices

  • Simplified tar Restore example
    • cd / ; tar zxvfp /Backup_Dir/Date.x.tgz home/user/directory/file_2_restore.txt

Simplified Debian Save and Restore Example
  • mount and unmount the floppy as needed ( it holds your system config )

  • Save System
      dpkg --get-selections * > /mnt/floppy/pkg.lst
      # You might want to save your important config files too
        tar zcvf /mnt/floppy/etc.tgz /etc

  • Restore System
    • build a minimally installed debian from cdrom or net install

      dpkg --set-selections < /mnt/floppy/pkg.lst
      # Check your important config files
        cd / ; tar zdvf /mnt/floppy/etc.tgz
      apt-get update
      apt-get dist-upgrade
        ( or apt-get dselect-upgrade ) ( or aptitude install )



Copyright © 2000
Linux-Consulting
All Rights Reserved.
Updated: Sun Nov 21 23:30:52 2004 PDT