Script to backup/restore pupsave

A home for all kinds of Puppy related projects
Post Reply
Message
Author
User avatar
r1tz
Posts: 162
Joined: Thu 09 Sep 2010, 05:19
Location: In #puppylinux (IRC)

Script to backup/restore pupsave

#1 Post by r1tz »

Made a simple clickable script to backup/restore pupsave in /mnt/home.
Remove the first two lines if you want to run in Prompt.
The backups are store only by date, so if you backup the same pupsave twice in a day, it will overwrite.

Code: Select all

#!/bin/sh
tail -n +4 $0  > /tmp/backupscript.txt
exec rxvt -e sh /tmp/backupscript.txt
DATE=`date +%e-%m-%y`
if [ -f /tmp/PUPSAVE ]
then
rm /tmp/PUPSAVE
fi
echo "[r]estore or [b]ackup"
read RB

if [ "$RB" = r ];then
FND_BACKUP="`find /mnt/home/ -maxdepth 3 -mount -type f -name *-??-??`"
echo "$FND_BACKUP" >> /tmp/PUPSAVE
NUM=`wc -l /tmp/PUPSAVE | tr -s ' ' | cut -f 2 -d ' '`

echo Choose which BackUp you would like to Restore.
   CHOOSE=1
   for ONECHOICE in `cat /tmp/PUPSAVE | tr '\n' ' '`
   do
    ONEPART="`echo -n "$ONECHOICE" | cut -f 1 -d ','`"
    echo -e "${CHOOSE}  ${ONEPART}"
    CHOOSE=`expr $CHOOSE + 1`
   done
 read SAVENUM
     PUPSAVE="`cat /tmp/PUPSAVE | tr '\n' ' ' | cut -f $SAVENUM -d ' '`"
NAME="${PUPSAVE%/*}"
NAME="${NAME%???}.${NAME:${#NAME}-3}"
echo $NAME
echo Are you sure? This will remove the previous Savefile. [y/n]
read sureornot
if [ "$sureornot" = n ];then
echo Goodbye
read
fi
if [ "$sureornot" = y ];then
echo removing $NAME
rm $NAME
echo Copying $PUPSAVE to $NAME...Auto-close when done.
cp -p "$PUPSAVE" "$NAME"
fi
fi

if [ "$RB" = b ];then
FND_PUPSAVE="`find /mnt/home/ -maxdepth 2 -mount -type f -name *save*.[23]fs`"
echo "$FND_PUPSAVE" >> /tmp/PUPSAVE
NUM=`wc -l /tmp/PUPSAVE | tr -s ' ' | cut -f 2 -d ' '`

case $NUM in
0)
echo No pupsave found
read
;;
1)
NAME="`echo $FND_PUPSAVE | tr -d "."`"
if [ -d $NAME ];then
echo $NAME exist.
else
mkdir $NAME
fi
echo Copying to $NAME ... Auto-Close when completed
cp -p "$FND_PUPSAVE" "$NAME/$DATE"
;;
*)echo Choose which save file you would like to backup.
   CHOOSE=1
   for ONECHOICE in `cat /tmp/PUPSAVE | tr '\n' ' '`
   do
    ONEPART="`echo -n "$ONECHOICE" | cut -f 1 -d ','`"
    echo -e "${CHOOSE}  ${ONEPART}"
    CHOOSE=`expr $CHOOSE + 1`
   done
 read SAVENUM
     PUPSAVE="`cat /tmp/PUPSAVE | tr '\n' ' ' | cut -f $SAVENUM -d ' '`"
NAME="`echo $PUPSAVE | tr -d "."`"
if [ -d $NAME ];then
echo $NAME exist.
else
mkdir $NAME
fi
echo Copying to $NAME ... Auto-Close when completed
cp -p "$PUPSAVE" "$NAME/$DATE"
;;
esac
fi
if [ -f "$NAME/ $DATE" ]
then
mv "$NAME/ $DATE" "$NAME/$DATE"
fi
rm /tmp/PUPSAVE
note:use at your own risk.

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#2 Post by goingnuts »

r1tz: This is a very interesting script! Could be interesting to expand it to only save what was added/changed since last save/backup (like done in the save to multi-session-cd) to save space and to do this automatic at shutdown. Maybe a setting for how many backups should be kept?

This would have spared me from totally messing up a save-file by doing wrong installs many times.

Like a roll-back opportunity if something goes wrong...

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#3 Post by 8-bit »

I am already using a well done script I got from the forum called pupsave-backup.
It goes a step further by doing a file system check on the backed up pupsave.
Also, the pupsave backup is made with date and time as part of the filename.
It has saved me a few times.

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#4 Post by goingnuts »

8-bit wrote:I am already using a well done script I got from the forum called pupsave-backup.
Any chance to point me to that script? Can't find it searching the forum...
You can normally revive a broken savefile using the "purge" boot options from the Puppy CD - but then you need to find the cd :) and it revert more or less to scratch.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#5 Post by 8-bit »

Ok, sorry.
I got the name wrong.
It is called hotbackup and a search of the forum will bring it up.
You can save the backup to any media you have and it does not have to be on the same drive.
It is only made for frugal installs though.

As to incremental backups, one might check out Snap2. It is supposed to make backups that only save changes made.
But be sure to read the documentation for it!

Post Reply