Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 25 Oct 2014, 13:50
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects
Script to backup/restore pupsave
Moderators: Flash, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
r1tz


Joined: 09 Sep 2010
Posts: 165
Location: In #puppylinux (IRC)

PostPosted: Fri 24 Sep 2010, 07:36    Post_subject:  Script to backup/restore pupsave  

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:
#!/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.
Back to top
View user's profile Send_private_message MSNM 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Sun 10 Oct 2010, 04:51    Post_subject:  

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...
Back to top
View user's profile Send_private_message Visit_website 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sun 10 Oct 2010, 05:00    Post_subject:  

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.
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Sun 10 Oct 2010, 05:12    Post_subject:  

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 Smile and it revert more or less to scratch.
Back to top
View user's profile Send_private_message Visit_website 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sun 10 Oct 2010, 13:14    Post_subject:  

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!
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Advanced Topics » Puppy Projects
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0541s ][ Queries: 12 (0.0042s) ][ GZIP on ]