Register
It is currently Thu Apr 24, 2014 4:48 pm

backup script (broken)


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Thu May 19, 2005 10:09 am   

Joined: Wed May 18, 2005 4:01 pm
Posts: 3
I'm sorry to say this isn't much, perhaps someone can post a fix as the include/exclude function does not seem to work



Code:
     #!/bin/bash
     # Create a compressed backup of all the directories specified and put       
     # the resulting file in a directory of our choice.
     # This is a hack created by freeballer using old script and info found
     # on the web.
     # (tar czvf /BackupJobs/${HOSTNAME}--$(date +%Y-%m-%d).tgz --files-from=/BackupJobs/system --exclude-from=/BackupJobs/exclude
     
     BACKUP_DIRS="
/usr/bin/backup.sh
/etc/
/root/
/home/freeballer/
/var/log
/mnt/Saved/BackupJobs/
/opt/mozilla/lib/firefox/searchplugins/
/var/lib/pacman/local
/Drivers
/mnt/WinXP/Documents and Settings/All Users/Start Menu/
/mnt/WinXP/Documents and Settings/All Users/Desktop/
/mnt/WinXP/Documents and Settings/Freeballer/Application Data/Ipswitch/
"
     BACKUP_FILES=""
     BACKUP_FILENAME=`date '+%Y-%m-%d'`
     BACKUP_DEST_DIR="/BackupJobs"
     EXCLUDE_EXT="*.iso *.img *.tgz *.pdf *.rar *.tar *.zip *.exe *.mpg *.avi *.mov *.gz"
     EXCLUDE_DIR="
   /home/freeballer/.pan/messages/cache
   /home/freeballer/.pan/Rogers
   /home/freeballer/.mozilla/firefox/3dkqh4dy.default/Cache
   /home/freeballer/.thumbnails
   /home/freeballer/My Documents"

     # We do a BZipped backup here...
     # Comment the following line for GZipped backups, uncomment for
     # BZipped backups

     tar czvf $BACKUP_DEST_DIR/${HOSTNAME}--$BACKUP_FILENAME.tgz $BACKUP_DIRS --exclude=$EXCLUDE_EXT --exclude=$EXCLUDE_DIR
#--wildcards-match-slash



Top
 Profile  
 PostPosted: Fri May 20, 2005 10:16 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
ok...i havn't tested it too well as i don't have much room on my hard disk (have to move some music files to another location)...
this should do the trick though
after looking at how tar works with the excludes i realized that it will only exclude files or a list of files contained in a file...
so what i did was quite simple...
using find i found all the files in the backed up directories that i wanted to exclude by using the particular extension...
once found they were added to a list...
once the list was compiled i then invoked tar using that list as an exclude list...
and here is what i got
Code:
#!/bin/bash

BACKUP_DIRS="/etc/
/root/
/home/
/var/log/"

EXCLUDE_BACKUP_EXT="iso
ogg
img
tgz
pdf
rar
tar
zip
exe
mpg
mpeg
avi
mov
gz"

BACKUP_FILENAME=`date '+%Y-%m-%d'`
BACKUP_DEST_DIR="/home/jbsnake/backups/"
cur_dir=`pwd`
echo "$EXCLUDE_BACKUP_EXT" > "${cur_dir}/excludelist.dat"
echo "$BACKUP_DIRS" > "${cur_dir}/dirs2backup.dat"


function create_exclude_list
{
   until ! read dir
   do
      until ! read extension
      do
         find "${dir}" -name "*.${extension}" 2> /dev/null >> "${cur_dir}/excludedfiles.dat"
      done < "${cur_dir}/excludelist.dat"
   done < "${cur_dir}/dirs2backup.dat"
}

create_exclude_list

tar --exclude-from "${cur_dir}/excludedfiles.dat" -czvf "${BACKUP_DEST_DIR}${HOSTNAME}--${BACKUP_FILENAME}.tgz" ${BACKUP_DIRS}

hope this helps :)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP