Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: filetool.sh hack, default or custom filename< Next Oldest | Next Newest >
spark-o-matic Offline





Group: Members
Posts: 68
Joined: Jan. 2008
Posted: Oct. 09 2008,23:18 QUOTE

Hi all,

I finaly did what I threatened to do and hacked filetool.sh so I can backup using the default backup.tar.gz or backup_(name).tar.gz from the command line.  These are the changes I made.

In Beaver I did a replace of all instances of backup.tar.gz with $BACKUPNAME.

At line 24 I inserted
Code Sample
if [ -z $4 ]; then
 BACKUPNAME="backup.tar.gz"
else
 BACKUPNAME="backup_$4.tar.gz"
fi


line 97 was changed to reflect the filename in addition to the device
Code Sample
   echo -n "${BLUE}Backing up files to ${MAGENTA}$MOUNTPOINT/$BACKUPNAME ${BLUE}mounted on ${MAGENTA}/dev/$DEVICE ${NORMAL}"

and the same change to line 125.

Changed the instructions on line 13 to reflect this change and the other command line options.
Code Sample
 echo "Usage: filetool.sh {backup|restore [null]|[non-null] device backup_name(changes file name to backup_(backup_name).tar.gz from backup.tar.gz}"

Code Sample
sudo filetool.sh backup z hdd4 project01_00
creates a backup to hdd4 named backup_project01_00.tar.gz

The only glitch I've found is argument $2 has to be non-null and I guess a space doesn't work.  Therefore I get the colorful line with the spinning thingy instead of tar being verbose. Perhaps an or in the if checking for $2 eq "verbose" (sure thats the wrong syntax) in addition to null.  I havn't tested it with blowfish. I am using DSL 4.4

I am using this to backup parts of my DSL/Apache web server hard drive install named by project and date stamped so I can roll back to an earlier version when something experimental fails.  

Thanks all
:D


--------------
The smartest person is not the person who knows the most.  
The smartest person is the one who knows which book to look in.
Community knowledge can be the sum of it's knowledge or the sum of it's ignorance
The Definition of a 'Brain Fart':
When something comes out of my brain that Stinks!
Back to top
Profile PM WEB 
chaostic Offline





Group: Members
Posts: 328
Joined: Mar. 2005
Posted: Oct. 10 2008,01:37 QUOTE

Cron job
"sudo filetool.sh backup z hdd4 project_$(date +%F)"

Makes the backup as backup_project_2008-10-09.tar.gz, if used today.

$(date +%Y_%m_%d) if you prefer
backup_project_2008_10_09.tar.gz instead :P
Back to top
Profile PM 
chaostic Offline





Group: Members
Posts: 328
Joined: Mar. 2005
Posted: Oct. 10 2008,01:40 QUOTE

Also, a space won't work for $2 because an unescaped space is treated as a whitespace. You could try
sudo filetool.sh backup \  hdd4 project_$(date +%F)

Note, two spaces after \

or
sudo filetool.sh backup " " hdd4 project_$(date +%F)
Back to top
Profile PM 
spark-o-matic Offline





Group: Members
Posts: 68
Joined: Jan. 2008
Posted: Oct. 10 2008,05:13 QUOTE

Hi chaostic

Quote
Also, a space won't work for $2 because an unescaped space is treated as a whitespace. You could try
sudo filetool.sh backup \  hdd4 project_$(date +%F)

Note, two spaces after \

or
sudo filetool.sh backup " " hdd4 project_$(date +%F)


Ok, note the last part of my signature (I must have had one of those).  If a character doen't work put a \, if a string doesn't work put it in quotes.  As long as I have been writing in PERL I should have known better.

The example was just by way of illustration of the functionality.  I hand name most old archive versions because I may not make a copy to roll back to until I am doing something thay may go completly wrong so I may call todays backup 2008_june.  But an automatic date stamp as an option wouldn't be hard. ???
(In fact I'm gonna give that a quick go right now)

Thanks


--------------
The smartest person is not the person who knows the most.  
The smartest person is the one who knows which book to look in.
Community knowledge can be the sum of it's knowledge or the sum of it's ignorance
The Definition of a 'Brain Fart':
When something comes out of my brain that Stinks!
Back to top
Profile PM WEB 
spark-o-matic Offline





Group: Members
Posts: 68
Joined: Jan. 2008
Posted: Oct. 10 2008,06:33 QUOTE

Ok, the inserted code becomes
Code Sample
if [ -n $5 ]; then
 if [ -z $4 ]; then
   BACKUPNAME="backup_$(date +%Y_%m_%d).tar.gz"
 else
   BACKUPNAME="backup_$4_$(date +%Y_%m_%d).tar.gz"
 fi
else
 if [ -z $4 ]; then
   BACKUPNAME="backup.tar.gz"
 else
   BACKUPNAME="backup_$4.tar.gz"
 fi
fi


And it needed "" instead of " " because -z is looking for a edit:* "null string" not a space.  I guess I was for some reason thinking whitespace could be a deliminator :p

*edit: null is the ASCII character 0 and -z looks for a string of 0 length or a "null string" not a null


--------------
The smartest person is not the person who knows the most.  
The smartest person is the one who knows which book to look in.
Community knowledge can be the sum of it's knowledge or the sum of it's ignorance
The Definition of a 'Brain Fart':
When something comes out of my brain that Stinks!
Back to top
Profile PM WEB 
4 replies since Oct. 09 2008,23:18 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: filetool.sh hack

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code