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 Tue 02 Sep 2014, 17:59
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 1 of 2 [27 Posts]   Goto page: 1, 2 Next
Author Message
jrb


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

PostPosted: Thu 22 Sep 2011, 13:25    Post subject:  Script makes dated backup files
Subject description: Create backups of files and folders with date and time
 

I started out thinking about backing up my Save files (warysave, lupusave, etc.) and wanted them to be identified by date and time as to when they were backed up so that I can choose which one to use when Puppy boots up.

This means copying them and renaming, i.e. warysaveA.3fs becomes warysave-11-09-22_10.13.3fs.

Once I got started writing a script however I realized that it might be handy for this to work on any file or folder so I set it up that way.

I have placed "mk_dated_backup" on the rox right click "Open With" menu.

Just right click on any file or folder, go to "Open With" and choose "mk_dated_backup". The backup will be created in the same folder as the original and a gxmessage will appear when it is finished.

I have attached dated_backup.pet-0.2

Enjoy, J Very Happy

Notes:
- Anything after the last dot (.) in a filename will be treated as an extension and placed after the date and time in the new filename.
- .pets will not work if you change their file name

Changelog
_____________________________
Version 0.2 (25 Sep 2011)
- Everything after the word "save" in a file name will be replaced with the time and date and the original extension.
- mk_dated_backup has been placed 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

Here's the new code:
Code:
#!/bin/sh
#Make a dated backup of any file or folder with same extension - jrb 22sep11
#Removal of previous dates on pupsave file - jrb 25sep11

#Notes - .pets will not work if you change their file name
#Anything after the last dot (.) in a filename will be treated as an extension
#and placed after the date and time in the new filename.


FILE=$@
FNAME=`basename $FILE`
FRST=${FNAME%%save*}
LAST=${FNAME##*save}
DIR=`dirname $FILE`
EXT1=${FILE##*.}

#if file has no extension must use the following:
if [ $FILE = $EXT1 ]
   then
      EXT2=""
   else      
      EXT2=.$EXT1
fi

#Everything after the word "save" in a file name will be
#replaced with the time and date and the original extension.
#This includes any descriptors you may have placed on your save file.
if [ $FRST = $LAST ]
   then
      OLDFILE=`basename $FILE .$EXT1`
   else
      OLDFILE="$FRST"save
fi

NEWFILE="$OLDFILE"-`date +%y-%m-%d_%H.%M`$EXT2

cd $DIR
cp -r $FILE $DIR/$NEWFILE

gxmessage -center -bg orange "Backup finished"
dated_backup-0.2.pet
Description  Create dated backups of files and folders
pet

 Download 
Filename  dated_backup-0.2.pet 
Filesize  1.39 KB 
Downloaded  230 Time(s) 

Last edited by jrb on Sun 25 Sep 2011, 16:51; edited 1 time in total
Back to top
View user's profile Send private message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

PostPosted: Thu 22 Sep 2011, 15:11    Post subject:  

Great thanks much appreciated but?
Don't get me wrong now but I got much bashing
when I supported that one could manually do something
similar.

Them told me rightly??? that one need to reboot and boot with pfix=ram before one can do what your script does? Maybe that is built in and me fail to grasp such code? I take a look again

_________________
I use Google Search on Puppy Forum
not an ideal solution though
Back to top
View user's profile Send private message 
jrb


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

PostPosted: Thu 22 Sep 2011, 15:18    Post subject:  

nooby wrote:
Them told me rightly??? that one need to reboot and boot with pfix=ram before one can do what your script does?

In theory one should, but I've been doing hot backups of my save files for years and the worst I've got is a message saying "This file doesn't seem to have shut down properly" and a choice to "ignore" or "cancel". When I choose "ignore" it then opens and runs properly, so far anyway Very Happy .
Back to top
View user's profile Send private message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

PostPosted: Thu 22 Sep 2011, 15:49    Post subject:  

Cool, so why do them get so upset with me Smile

Maybe them love to tell me I am wrong. I don't blame them.

They want only the best for Puppy so that is a good thing.

So how do you use that script then. What is it about it that you like?
When is the proper time to do such back ups? Okay directly after one made a change? A new install of a pet or updating Firefox?

_________________
I use Google Search on Puppy Forum
not an ideal solution though
Back to top
View user's profile Send private message 
jrb


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

PostPosted: Thu 22 Sep 2011, 18:45    Post subject:  

nooby wrote:
Cool, so why do them get so upset with me Smile

Maybe some people just need to get upset? Confused
nooby wrote:
So how do you use that script then. What is it about it that you like?
When is the proper time to do such back ups? Okay directly after one made a change? A new install of a pet or updating Firefox?

I like to make a backup save file right after I first use a new Puppy (pupsaveA.3fs). This means just start the puppy, get video, internet, etc. working and then reboot and save.

Then BEFORE I make a major addition or change I create a backup file. When I'm working on new scripts or changes in software it's very comforting knowing if I screw up it's just a matter of rebooting and going back to my last backup and I haven't lost anything. With the date and time on them I can tell at a glance which is the most recent.

Also, when I'm developing a new script I like to back up the script file at each change so if the change doesn't work I can go back to a version that does. Here again having the date and time on the backups is very convenient.

I've just created this script this morning, I'm sure I'll think of more uses for it as I go along. Surprised

Give it a try and see what you think.

Cheers, J
Back to top
View user's profile Send private message 
faifpuhp


Joined: 22 Sep 2011
Posts: 97

PostPosted: Thu 22 Sep 2011, 19:29    Post subject:  

Neat idea. Is it worth adding a list of md5sums or something?
_________________
Strawberry is dead!
Back to top
View user's profile Send private message 
jrb


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

PostPosted: Thu 22 Sep 2011, 20:12    Post subject:  

faifpuhp wrote:
Neat idea. Is it worth adding a list of md5sums or something?

Do you mean generate an md5sum with each backup? Could be handy for files that are to be uploaded but otherwise might just be more clutter.
Back to top
View user's profile Send private message 
faifpuhp


Joined: 22 Sep 2011
Posts: 97

PostPosted: Thu 22 Sep 2011, 20:16    Post subject:  

jrb wrote:
Could be handy for files that are to be uploaded but otherwise might just be more clutter.


Yeah, it totally depends on what you had in mind originally. If there's a place for such a list, and it doesn't quadruple the size of everything, it might make sense. Otherwise it could easily be overkill.

_________________
Strawberry is dead!
Back to top
View user's profile Send private message 
jrb


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

PostPosted: Thu 22 Sep 2011, 20:17    Post subject:  

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 Confused

Not a huge problem. I guess when it gets too long I can just manually rename. I'm open to suggestions.
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3365
Location: Oregon

PostPosted: Thu 22 Sep 2011, 21:02    Post subject:  

How does this compare to hotbkp.targz which when unpacked becomes Pupsave-backup.
With it, available space is checked, the date and time are appended to the pupsave name, the pupsave does not have to be unmounted, the destination is selectable, and a file system check is done on the created file.
The file names it creates are fairly long too. An example would be "lupusave-500.2fs.BKP-11.02.18-22.09" which would say the backup was done on YY.MM.DD-HH.MM
That utility was made by 2byte.
Back to top
View user's profile Send private message 
faifpuhp


Joined: 22 Sep 2011
Posts: 97

PostPosted: Thu 22 Sep 2011, 21:07    Post subject:  

8-bit wrote:
The file names it creates are fairly long too. An example would be "lupusave-500.2fs.BKP-11.02.18-22.09" which would say the backup was done on YY.MM.DD-HH.MM
That utility was made by 2byte.


In the case of this thread, an unintended "feature" is the dates in the name "stack" on subsequent reboots. Perhaps 2byte's version accounts for this, but if someone has a trivial way around it, it might still be cool to fix the script in this thread, or maybe 2byte's version can offer a clue as to how.

_________________
Strawberry is dead!
Back to top
View user's profile Send private message 
jrb


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

PostPosted: Thu 22 Sep 2011, 21:57    Post subject:  

8-bit wrote:
How does this compare to hotbkp.targz which when unpacked becomes Pupsave-backup.
With it, available space is checked, the date and time are appended to the pupsave name, the pupsave does not have to be unmounted, the destination is selectable, and a file system check is done on the created file.

I tried hotbkp when it first came out. My main problem with it was that the backed up save file had to be renamed before it could be used since the file extension, .2fs or .3fs, ended up in the middle of the name.

Took me quite a while to get around to working on a solution and now as I mentioned in the 1st post I like the idea of using it to backup other files as well.
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 11034
Location: Arizona USA

PostPosted: Thu 22 Sep 2011, 23:39    Post subject:  

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


Joined: 03 Apr 2007
Posts: 3365
Location: Oregon

PostPosted: Fri 23 Sep 2011, 01:11    Post subject:  

Ok, you do not like having to rename the backed up files for a restore to a previous backed up pupsave.
So why not automate the process by including a restore pupsave section to your script with ability to specify pupsave backup location.
You would select the backup you wanted to restore, use sed to remove the date-time part of the name and then do an overwrite of the existing pupsave.
If done correctly, you then have automated the process of restoring and also taken care of mulitiple date-time additions to the filename on a backup.

It would make your simple backup script grow a little, but the end result would be nice.
Of course one thing you have not mentioned is that it is a bad idea to replace a mounted pupsave that is on your disk with another while the one you are replacing is in use.
Back to top
View user's profile Send private message 
nooby

Joined: 29 Jun 2008
Posts: 10557
Location: SwedenEurope

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

Thanks JRB,

So 8-bit how does 2byte take care of this part?
Quote:
Of course one thing you have not mentioned is that it is a bad idea to replace a mounted pupsave that is on your disk with another while the one you are replacing is in use.

How does his script know that it is not in use?

And same question. How did Barry know when he did that script for the Multisession? Or maybe that one only does it when it is to shut down?

Could one not then do a faked shut down. One start on it but not follow through? That way one don't have the pupsave in usage but after the backup one make use of it without shutting down.

I know too little.

_________________
I use Google Search on Puppy Forum
not an ideal solution though
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [27 Posts]   Goto page: 1, 2 Next
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.0940s ][ Queries: 13 (0.0085s) ][ GZIP on ]