Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Add  exclusion file to backup/restore, Backup home directories except xxx< Next Oldest | Next Newest >
hawki Offline





Group: Members
Posts: 175
Joined: Jan. 2004
Posted: May 15 2005,12:53 QUOTE

I would like to see the following changes made to the backup/restore script (filetool.sh).  Now the script backs up files and directories listed in filetool.lst and only excludes Cache.  I would like to add the ability to exclude files or directories within the listed directories.  To do that I added an exclusion file (xfiletool.lst) and added Cache to it.  This would allow you to add the whole home directory of dsl and any other users to filetool.lst and exclude files inside them that are large and not changing by adding them to xfiletool.lst.  One such file is XUL.mfasl under the .mozilla directory.  If it is not there it gets recreated at runtime.  Backing up that file adds upwards of .5MB to the backup file.  It sometimes gets much larger.  If you have added users and are backing up their home directories as well this can be huge.  There are probably other files like this that others are aware of.


******************************************************************************
The following is the filetool.sh script.  I commented out the original lines and
added my change directly below.
******************************************************************************

#!/bin/bash
# Original script by Robert Shingledecker for John Andrews DSL
# © Robert Shingledecker 2003,2004,2005
# A simple script to save/restore configs, directories, etc defined by the user
# in the file filetool.lst
. /etc/init.d/dsl-functions


HOME="/home/dsl"

if [ -z $1 ] ; then
 echo "Usage: filetool.sh {backup|restore}"
 echo -n "Press enter to coninue:" ; read ans
 exit 1
fi

DEVICE="$3"

if [ -z $DEVICE ]; then

#echo "Get the device name from /opt/.backup_device
if [ -e /opt/.backup_device ]; then
  if [ -n /opt/.backup_device ]; then
    DEVICE=`cat /opt/.backup_device`
  fi
fi
fi

get_mountpoint $DEVICE


if [ -z "$MOUNTPOINT" ]; then
 echo "Invalid device $DEVICE"
 echo -n "Press enter to coninue:" ; read ans
 exit 1
fi

if [ $MOUNTED == "no" ]; then
  sudo mount $MOUNTPOINT
  if [ "$?" != 0 ]; then
     echo "Unable to mount device $DEVICE"
     echo -n "Press enter to coninue:" ; read ans
     exit 1
  fi
fi

echo `basename "$DEVICE"` > /opt/.backup_device

if [ $1 == "backup" ] ; then
 if [ -z $2 ]; then






#    tar -C / -T $HOME/filetool.lst --exclude=Cache -czvf $MOUNTPOINT/backup.tar.gz
   tar -C / -T $HOME/filetool.lst --exclude-from=$HOME/xfiletool.lst -czvf $MOUNTPOINT/backup.tar.gz
   echo -n "Press enter to coninue:" ; read ans
 else
   echo -n "${BLUE}Backing up files to $MOUNTPOINT ${NORMAL}"




#   tar -C / -T $HOME/filetool.lst --exclude=Cache -czf $MOUNTPOINT/backup.tar.gz 2>/dev/null &
#    rotdash $!

  tar -C / -T $HOME/filetool.lst --exclude-from=$HOME/xfiletool.lst -czf $MOUNTPOINT/backup.tar.gz 2>/dev/null &
   rotdash $!

   if [ -f /etc/sysconfig/des ]; then
      KEY=$(cat /etc/sysconfig/des)
      des -E -3 -k "$KEY" "$MOUNTPOINT/backup.tar.gz" "$MOUNTPOINT/backup.des"
      rm -f "$MOUNTPOINT/backup.tar.gz"
   fi
   echo "${BLUE}Done.${NORMAL}"
 fi
 if [ $MOUNTED == "no" ]; then
  sudo umount $MOUNTPOINT
 fi
 exit 0
fi

if [ $1 == "restore" ] ; then
 if [ -f /etc/sysconfig/des ]; then
    TARGETFILE="backup.des"
 else
    TARGETFILE="backup.tar.gz"
 fi
 if [ ! -f $MOUNTPOINT/$TARGETFILE ] ; then
    if [ $MOUNTED == "no" ]; then
     sudo umount $MOUNTPOINT
    fi
 fi
 if [ -z $2 ]; then
   tar -C / -zxvf $MOUNTPOINT/backup.tar.gz
   echo -n "Press enter to coninue:" ; read ans
 else
   echo -n "${BLUE}Restoring backup files from $MOUNTPOINT ${NORMAL}"
   if [ -f /etc/sysconfig/des ]; then
      KEY=$(cat /etc/sysconfig/des)
      des -D -3 -k "$KEY" "$MOUNTPOINT/backup.des" "$MOUNTPOINT/backup.tar.gz"
   fi
   tar -C / -zxf $MOUNTPOINT/backup.tar.gz 2>/dev/null &
   rotdash $!
   if [ -f /etc/sysconfig/des ]; then
      rm -f "$MOUNTPOINT/backup.tar.gz"
   fi
   echo "${BLUE}Done.${NORMAL}"
 fi
 if [ $MOUNTED == "no" ]; then
  sudo umount $MOUNTPOINT
 fi
 exit 0
fi
echo "I don't understand the command line parameter: $1"
echo "Usage: filetool.sh {backup|restore}"
echo -n "Press enter to coninue:" ; read ans
exit 1







****************************************************************
The following is the contents of my filetool.lst file.  
I backup my added user hawki home directory also.
***************************************************************



opt/ppp
opt/bootlocal.sh
opt/powerdown.sh
opt/.mydsl_dir
home/dsl
home/hawki
etc/group
etc/passwd
etc/shadow
etc/sudoers



***************************************************************
The following is the contents of my xfiletool.lst file.
This excludes Cache and XUL.mfasl from the backup file for
both users.
***************************************************************



Cache
XUL.mfasl
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: May 15 2005,14:43 QUOTE

Very cool.  So the only difference is adding --exclude-from?

--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: May 15 2005,17:14 QUOTE

hawki, Very Nice! Thanks for sharing.

mikshaw, yes the excude and exclude-from is the only change.

A simple sed command will produce the new script.

sed 's~=Cache~-from=$HOME/xfiletool.lst~' /usr/sbin/filetool.lst > filetool.lst

Then to try out the "new" filetool.lst from /home/dsl

./filetool.lst backup
Back to top
Profile PM WEB 
hawki Offline





Group: Members
Posts: 175
Joined: Jan. 2004
Posted: May 15 2005,23:17 QUOTE

Hi
Thanks for the quick response.  Yes the --exclude-from= is the change.  In fact it looks like -X does the same thing.
It makes a big difference on backup size in some cases.

Thanks again
Back to top
Profile PM 
pr0f3550r Offline





Group: Members
Posts: 378
Joined: Dec. 2005
Posted: Feb. 20 2006,19:41 QUOTE

I wonder if adding the -u (--update) argument to tar in filetool.sh would make the backup faster and wear the usb stick less

--------------
THE QEMU FORUM: http://qemu.dad-answers.com/index.php

QEMU ON WINDOWS: http://www.h7.dion.ne.jp/~qemu-win/

How to use floppy, CD-ROM and hard disk - http://www.h7.dion.ne.jp/~qemu-win/HowToFloppyCdrom-en.html

How to use network - http://www.h7.dion.ne.jp/~qemu-win/HowToNetwork-en.html
Back to top
Profile PM 
4 replies since May 15 2005,12:53 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Add  exclusion file to backup/restore

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code