How to (semi-)automatically back up your pupsave

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
PaulBx1
Posts: 2312
Joined: Sat 17 Jun 2006, 03:11
Location: Wyoming, USA

How to (semi-)automatically back up your pupsave

#1 Post by PaulBx1 »

Backing up the pupsave is important to do, but it is a pain in the butt to do it with standard Puppy. I have put together a bit of code that makes it effortless. This is the end result of the discussion here.

I have been backing up this way for quite a while now and it is painful whenever I need to go back to the old way with an unmodified puppy.

The way it works is this. On shutdown, there is a query asking whether you want to back up the pupsave. If you say "y", it backs it up in a previously specified location; there are as many backups there as you want to specify (for example, if you want the 4 latest backups, when you do a new one the oldest one already there is deleted). After the backup is finished, the shutdown completes. If you say "n", the shutdown simply completes as is normal. If you say nothing (for example, you've walked off after telling Puppy to shut down), after 20 seconds it times out and completes the shutdown without backing up.

The following description assumes you have Puppy 4.3.1, or a Puppy with the same /etc/rc.d/rc.shutdown as Puppy 4.3.1 has (toward the end of that file).

1) Before making this modification, manually back up your pupsave. This modification has the potential, if done wrong, to cause you a lot of heartache, so a backup will let you recover easily.

2) Create the backup specification file. In /etc/rc.d create a file called "PUPBACKUP" (yes, all caps) containing these lines:

Code: Select all

PUPSAVEBACKUPDIR='/initrd/mnt/dev_save/backup/pupsaves'
PUPSAVEBACKUPCOUNT=3
The first line says where you want to put the backups. The second shows how many old backups you want to keep (there will actually be the current backup with a "0" appended to the file name, and in this case 3 older backups). You may of course modify the specifications; however keep in mind the destination directory must be located on an already mounted disk.

3) Edit /etc/rc.d/rc.shutdown. Locate the following line; it should be toward the end of the file:

Code: Select all

umount-FULL -i -n -l /initrd/${SAVE_LAYER} 2>/dev/null #-l is lazy unmount.
After that line, insert the following code:
[code]################### Added for pupsave backup - PJB ################################################
if [ -f /etc/rc.d/PUPBACKUP ]; then # Execute PUPBACKUP to specify backup info if available
. /etc/rc.d/PUPBACKUP
fi
if [ "$PUPSAVEBACKUPDIR" ]; then # A backup directory specified in PUPBACKUP?
echo -n "Back up your pupsave to ${PUPSAVEBACKUPDIR}? : " > /dev/console
read -t 20 response
if [ "$?" = "0" ]; then # User responded in timeout period?
if [ "$response" = "y" ]; then # User responded with "y"?
mkdir -p $PUPSAVEBACKUPDIR
while [ $PUPSAVEBACKUPCOUNT -gt 0 ]; do # Shift older backup files a notch
mv ${PUPSAVEBACKUPDIR}${SAVEFILE}$[ PUPSAVEBACKUPCOUNT - 1 ] ${PUPSAVEBACKUPDIR}${SAVEFILE}${PUPSAVEBACKUPCOUNT}
let PUPSAVEBACKUPCOUNT=PUPSAVEBACKUPCOUNT-1
done
echo "${SMNTPT}${SAVEPATH}${SAVEFILE} being copied to ${PUPSAVEBACKUPDIR}${SAVEFILE}0" > /dev/console
# CURRENTPUPSAVE="/initrd$(losetup $(mount | grep pup_rw | grep -v union |cut -f 1 -d ' ') | cut -f 3 -d ' ')"
# cp -a ${CURRENTPUPSAVE} ${PUPSAVEBACKUPDIR}${SAVEFILE}0
# cp -a ${SMNTPT}${SAVEPATH}${SAVEFILE} ${PUPSAVEBACKUPDIR}${SAVEFILE}0
cp -a /initrd/mnt/dev_save${SAVEFILE} ${PUPSAVEBACKUPDIR}${SAVEFILE}0
sync
fi
fi
fi
####################### End of addition for pupsave backup ########################################
[/code]


That's it! Shut down Puppy, and see if it works.

Notice, I am not an experienced bash coder. I had a little trouble getting this to work the way I wanted to - for example, I had to hard code "initrd/mnt/dev_save" at the end. Maybe someone more experienced can improve it.

don922
Posts: 433
Joined: Sat 19 Jan 2008, 07:58
Location: Nong Yai Buah

Didn't Work

#2 Post by don922 »

Puppy 4.12 retro, frugal install

I am using the method for clean unmounting the pup_save.2fs described here: http://www.murga-linux.com/puppy/viewto ... 535#420535
(Note: I have gone back and removed this code -- however I still get the same results described below)

I, also, have included your code in the /etc/rc.d/rc.shutdown.

At shutdown I am asked if I want to save the pup_save.2fs file and I answer yes by entering> y (enter)
The program tells me it is saving a file pup_save-412retro.2fs0, each time.

On the next boot there is nothing in the /initrd/mnt/dev_save/backup/pupsaves file

What could be wrong?
[color=green][i]Don -- Thailand[/i][/color]
[url=http://www.puppylinux.com][img]http://tinypic.com/4e0tojl.jpg[/img][/url]

PaulBx1
Posts: 2312
Joined: Sat 17 Jun 2006, 03:11
Location: Wyoming, USA

#3 Post by PaulBx1 »

Sorry I didn't see this question for months...
On the next boot there is nothing in the /initrd/mnt/dev_save/backup/pupsaves file
It is a directory (folder), not a file. Could that be the problem? Also the destination must be mounted, and there must be enough room on the drive.

ocpaul20
Posts: 260
Joined: Thu 31 Jan 2008, 08:00
Location: PRC

#4 Post by ocpaul20 »

Puppy 510 frugal

I have just tried to put this into puppy 510 and it does the same thing. It does not write to my dev-save directory either, which is on sda3. Is there any way we can run it from a console, stop it before the end and see what messages it has output? We can always do a 'halt' afterwards manually.

I realise that puppy 510 has an extra 'if statement' tacked on the end of the shutdown script, but essentially it is the same though.

# mount -l gives me this
/dev/sda3 on /initrd/mnt/dev_save type ext2 (rw,noatime,errors=continue) [puppy_lupu]

I am just wondering if it is trying to do the copy too late and something has become read-only or unmounted perhaps? The machine carries on and powers down but does not output an error message or does not do the copy.

PaulBx1
Posts: 2312
Joined: Sat 17 Jun 2006, 03:11
Location: Wyoming, USA

#5 Post by PaulBx1 »

Might try putting a "sleep 120" at the end of that code, to give it time to complete. I'm on 511 now and haven't changed my shutdown on that version yet. I may some day since I'm bad at doing regular backups. However I have also moved my email files off the pupsave so I don't need backups that often either. I am moving toward having little in the pupsave and no frequently-changed data, which I think is a better way to do it.

ocpaul20
Posts: 260
Joined: Thu 31 Jan 2008, 08:00
Location: PRC

#6 Post by ocpaul20 »

OK, thanks. I'll try that and see what happens.

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#7 Post by nooby »

PaulBx1 wrote:Might try putting a "sleep 120" at the end of that code, to give it time to complete. I'm on 511 now and haven't changed my shutdown on that version yet. I may some day since I'm bad at doing regular backups. However I have also moved my email files off the pupsave so I don't need backups that often either. I am moving toward having little in the pupsave and no frequently-changed data, which I think is a better way to do it.
May I kindly ask for a description on how one do such things then?

I tried doing this for Firefox on Luci234 but ended up not getting access to launch it and had to start all over.

.mozilla moved to the partition with NTFS that has frugal install of Puppy on it named /mnt/home

Some say one should rename it to mozilla after the move. Is that essential I kept it as .mozilla could that be why it failed?
I use Google Search on Puppy Forum
not an ideal solution though

Post Reply