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
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.
[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.