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

Simple front end to the 'dump' backup program


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Fri Dec 02, 2011 10:36 am   
User avatar

Joined: Sat Jul 02, 2011 10:43 am
Posts: 23
Location: Devon,UK
I use the dump program that comes with most linux distros and to make life easier I thought I would write this simple menu driven front end, you must be root to run this and obviously have the dump program installed, it's fairly self explanatory, the disk to be dumped must be mounted so it can be found.
To restore a previously saved file system just cd into a ( preferably freshly formatted ) file sytem and run
Code:
sudo restore -arvf "/path/to/saved/dump/file".

Enjoy!
Code:
#!/bin/bash

#check for root
if [ $UID -gt 0 ];then
   echo "You are NOT root, go away!"
   exit 1
fi

#init stuff
PATHTODUMP="$(which dump)"
if [ "X${PATHTODUMP}" = "X" ];then
   echo "I Can't find 'dump' :("
   exit 2
fi

#to dump a disk it must be mounted
echo "Please select a disk to save"
DISKTOSAVE=$(mount|grep "/media"|awk '{print $3}'|awk -F "/" '{print $3}')

select THENAME in $DISKTOSAVE
   do
      DEV=$(blkid -L "$THENAME")
      break
   done

#select the dest disk ( must be mounted )
echo "Please select a save folder"
DATA=$(mount|grep "/media"|awk '{print $3}'|awk -F "/" '{print $3}')

select NAME in $DATA
   do
      DEST="/media/$NAME"
      break
   done

#selecting "Print" will just print the command
echo "Please select what to do on finish"
select FINISH in "Nothing" "Shutdown" "Restart" "Print"
   do
      break
   done

#if you don't have zlib installed you can remove/change -z9 see the dump man page
#always does a level 0 dump
FOLDER=${DEST/\/dev\//\/media\/}
if [ $FINISH = "Print" ];then
   echo "$PATHTODUMP -z9 -0 -f \"${FOLDER}/LinuxBackups/${THENAME}.$(date +%y%m%d)\" \"$DEV\""
   exit
fi

mkdir -p "${FOLDER}/LinuxBackups"
umount "$DEV"

$PATHTODUMP -z9 -0 -f "${FOLDER}/LinuxBackups/${THENAME}.$(date +%y%m%d)" "$DEV"

case $FINISH in
   "Nothing")
      exit
      ;;
   "Shutdown")
      poweroff -d
      ;;
   "Restart")
      reboot -d
      ;;
esac


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 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:  
cron


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