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 Wed 01 Oct 2014, 16:49
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to (semi-)automatically back up your pupsave
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
PaulBx1

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Sun 16 May 2010, 15:02    Post_subject:  How to (semi-)automatically back up your pupsave  

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:

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:
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 ########################################


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

Joined: 19 Jan 2008
Posts: 380
Location: The land of 14" monitors

PostPosted: Sun 30 May 2010, 04:27    Post_subject:  Didn't Work  

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/viewtopic.php?p=420535#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?

_________________
Don -- Thailand

Back to top
View user's profile Send_private_message 
PaulBx1

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Thu 28 Oct 2010, 14:20    Post_subject:  

Sorry I didn't see this question for months...

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

Joined: 31 Jan 2008
Posts: 189
Location: Right on top of CERN

PostPosted: Mon 01 Nov 2010, 06:04    Post_subject:  

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

Joined: 16 Jun 2006
Posts: 2308
Location: Wyoming, USA

PostPosted: Tue 23 Nov 2010, 00:01    Post_subject:  

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

Joined: 31 Jan 2008
Posts: 189
Location: Right on top of CERN

PostPosted: Tue 23 Nov 2010, 00:20    Post_subject:  

OK, thanks. I'll try that and see what happens.
Back to top
View user's profile Send_private_message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

PostPosted: Tue 23 Nov 2010, 03:02    Post_subject:  

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
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 » House Training » HOWTO ( Solutions )
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.0819s ][ Queries: 12 (0.0172s) ][ GZIP on ]