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 23 Aug 2014, 11:20
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Script makes dated backup files
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [27 Posts]   Goto page: Previous 1, 2
Author Message
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Fri 23 Sep 2011, 04:55    Post subject:  

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.
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Fri 23 Sep 2011, 05:07    Post subject:  

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:

#! /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.
Back to top
View user's profile Send private message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

PostPosted: Fri 23 Sep 2011, 06:06    Post subject:  

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 Smile

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
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Fri 23 Sep 2011, 15:59    Post subject:  

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.
Back to top
View user's profile Send private message 
jrb


Joined: 11 Dec 2007
Posts: 1032
Location: Smithers, BC, Canada

PostPosted: Fri 23 Sep 2011, 16:41    Post subject:  

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.
Back to top
View user's profile Send private message 
jrb


Joined: 11 Dec 2007
Posts: 1032
Location: Smithers, BC, Canada

PostPosted: Fri 23 Sep 2011, 16:46    Post subject:  

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
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Fri 23 Sep 2011, 19:25    Post subject:  

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:

#! /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
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3254
Location: Ontario

PostPosted: Sat 24 Sep 2011, 14:17    Post subject: pschedule to backup a pupsave file  

I describe how to use pschedule to backup a pupsave file

http://www.murga-linux.com/puppy/viewtopic.php?p=567279#567279

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

____________________________________________________--
Back to top
View user's profile Send private message 
jrb


Joined: 11 Dec 2007
Posts: 1032
Location: Smithers, BC, Canada

PostPosted: Sat 24 Sep 2011, 14:35    Post subject: Re: pschedule to backup a pupsave file  

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. Very Happy
Back to top
View user's profile Send private message 
jrb


Joined: 11 Dec 2007
Posts: 1032
Location: Smithers, BC, Canada

PostPosted: Sat 24 Sep 2011, 14:48    Post subject:  

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 Embarassed , maybe I just dreamed it?) Will duplicate soon.

Cheers, J
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3364
Location: Oregon

PostPosted: Sat 24 Sep 2011, 15:35    Post subject:  

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:

#! /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
Back to top
View user's profile Send private message 
jrb


Joined: 11 Dec 2007
Posts: 1032
Location: Smithers, BC, Canada

PostPosted: Sun 25 Sep 2011, 17:01    Post subject:  

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. Very Happy It also deletes anything else after the word "save" in anyfile its used on Rolling Eyes 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
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [27 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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