Script makes dated backup files

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

#16 Post by 8-bit »

nooby,
2byte does not have a restore option in his script.
With it, you rename the backed up pupsave before copying it back to the correct directory replacing the one that is there.

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

#17 Post by 8-bit »

jrb,
I do not know if this would help and it is designed so as to have the backed up pupsave name in the format of "pupsave-520.sfs.BAK.yy.mm.dd.hh.mm"
But I am sure you could adjust it as needed.
I also leave it up to you to change the line that I have an example backed up pupsave name in.
Maybe use =%1.
But here is a short script for you to try.

Code: Select all

#! /bin/bash
PSNAME='pupsave-500-23.2fs.BAK-11.20.02.12.30'
newname=`echo $PSNAME | sed "s/...................$//"`  #That is 19 periods there.
echo PSNAME = $PSNAME
echo newname = $newname
It will take a supplied name and remove all the BAK-date-time stuff and leave you with a clean pupsave file name that can be copied back in on a restore.
Given a little time, I could write a restore script for restoring from a saved backup of pupsave-xxx.2fs.

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

#18 Post by nooby »

Thanks 8-bit.
That explains it then. One rename it before restore.

TinyCore has a back up and restore function that is already built in.
So would be interesting to get how them do that feature :)

What about this .2fs and .3s some puppies one have .2fs and for some one have .3fs out of habit or curiosity. Would one need two different such scripts then?
I use Google Search on Puppy Forum
not an ideal solution though

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

#19 Post by 8-bit »

nooby, if you copy the short script into geany, save it and nake it executable, you can edit the line in geany that defines PSNAME.
Put any pupsave name and type in there replacing the "pupsave-500-23.2fs" with any name you want to try it with such as warysave-2000.3fs or noobysave-01.4fs.
It will still work fine.
The only thing here is that it expects the pupsave backup name to be in a given format.
If the 2fs or 3fs extension is at the end of the name with the date-time stamp in the middle, then you have to change the way it is parsed to get a resulting name without the time-date stamp.
With a little effort, a GUI could be made that supports drag and drop for input of the filename.

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#20 Post by jrb »

Flash wrote:Multisession Puppy creates dated session names. Each session it saves on the DVD is named with the date and time it was created. How the Save script does that I have no idea. I just thought you might find it interesting to compare it to your way.
Thanks Flash, I'll check out /etc/rc.shutdown and see if I can figure out how Barry does it.

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#21 Post by jrb »

8-bit wrote:use sed to remove the date-time part of the name
Thanks for jogging my brain cells. I'll see what I can do with sed and I'm sure I can build in an IF statement which will treat 2fs, 3fs, and 4fs files differently than other files.

Will get back to you, J

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

#22 Post by 8-bit »

jrb,
My main problem is not knowing the pupsave name the user gives his save file.
That complicates knowing what to look for in removing the date-time part of the filename.

But if this will help you any at all, you can check this code for the format you use. It is very rough and you need to run it from a terminal to see that it does indeed remove the date-time from the filename.
But I am not sure of how to look for an unknown end of the initial filename before the date-time is added. Maybe I can use the dash.
Will get back to you.
EDITED: Dash works and also deleted dash

Code: Select all

#! /bin/bash
PSNAME='warysaveA-11-09-22_10.13.3fs'
newname=`echo $PSNAME | sed 's/-.*.3fs/-.3fs/' | sed 's/-//'`
echo PSNAME = $PSNAME
echo newname = $newname

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

pschedule to backup a pupsave file

#23 Post by don570 »

I describe how to use pschedule to backup a pupsave file

http://www.murga-linux.com/puppy/viewto ... 279#567279

I made only a slight change to your script to do the
rename and copy.

____________________________________________________--

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

Re: pschedule to backup a pupsave file

#24 Post by jrb »

don570 wrote:I describe how to use pschedule to backup a pupsave file

I made only a slight change to your script to do the
rename and copy.
Excellent, saves me the bother of having to work out a GUI. :D

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#25 Post by jrb »

jrb wrote:I just realized that a backup of a file previously backed up gives the date and time of both backups, i.e. warysave-11-09-11_12.30-11-09-22_15.25.3fs
I worked on this last night and came up with a solution which works nicely on pupsave files but may have difficulties with a few other filenames (if they have "save" in the name). Will try to get back to it soon and post script. (Seem to have misplaced the work I did :oops: , maybe I just dreamed it?) Will duplicate soon.

Cheers, J

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

#26 Post by 8-bit »

I also have been playing expanding on don570's work and trying to set up a Restore script.
One would have to have booted with pfix=ram and be in the frugal directory for the restore of the backed up pupsave.
If you are brave, you can remove the last 4 comment markers in the script and comment out the hardwired PSNAME and uncomment the line below it to try it. Naturally comment markers are "#".
I did this so no one would get problems if they just ran it as is.

Code: Select all

#! /bin/bash
PSNAME='warysaveA-11-09-22_10.13.4fs'
#PSNAME=$@
FNAME=`basename $PSNAME`
DIR=`dirname $PSNAME`
EXT1=${FNAME##*.}
#if file has no extension must use the following:
if [ $FNAME = $EXT1 ]
	then
		EXT2=""
	else		
		EXT2=.$EXT1
fi
if [ $EXT2 = ".3fs" ]
    then
    newname=`echo $PSNAME | sed 's/-.*.3fs/-.3fs/' | sed 's/-//'`
fi
if [ $EXT2 = ".2fs" ]
    then
    newname=`echo $PSNAME | sed 's/-.*.2fs/-.2fs/' | sed 's/-//'`
fi
if [ $EXT2 = ".4fs" ]
    then
    newname=`echo $PSNAME | sed 's/-.*.4fs/-.4fs/' | sed 's/-//'`
fi
#cd $DIR
#cp -r $DIR/$PSNAME $DIR/$newname
#sync
#xmessage "Restore completed"


echo PSNAME = $PSNAME
echo newname = $newname
echo EXT2 = $EXT2
echo Directory = $DIR

User avatar
jrb
Posts: 1536
Joined: Tue 11 Dec 2007, 19:56
Location: Smithers, BC, Canada

#27 Post by jrb »

I just uploaded dated_backup-0.2.pet in the first post.

This one deletes out previous times and dates in "save" files and places in the latest date. :D It also deletes anything else after the word "save" in anyfile its used on :roll: but I can live with that.

I have also placed it on the rox right click menu for .2fs, .3fs, .4fs, scripts and plain text. For all other files it is still on the OpenWith menu.

Barring any unforeseen catastrophes I think I'm finished with this. Anyone who wishes to use the code or make improvements - go for it.

Cheers, J

Post Reply