Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 12th, 2006, 11:00 AM
davidb2002's Avatar
davidb2002 davidb2002 is offline
Almighty God of Nothing
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Location: Rotherham, UK
Posts: 712 davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 6 h 35 m 41 sec
Reputation Power: 91
Send a message via ICQ to davidb2002
Exclamation Simple Cron Backup (Howto?)

Yes, another "how to cron" question from another linux newbie. I searched google and read in the forums for anything to do with Crons and cannot find any strait explanation of how to run the following command at 12:01am everyday.

Here is the command:
tar cvf /dev/st0 /usr

Step-by-step help required here. Thanks to all that help out!

Reply With Quote
  #2  
Old July 12th, 2006, 12:07 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
Be in the user for whom the cron is to be run for.

crontab -e

insert a new line like:

01 12 * * * tar cvf /dev/st0 /usr

That will run at 1 minute past midday. If you need it for 1 minute past midnight use:

01 0 * * * tar cvf /dev/st0 /usr

Both will run at the specified times, 7 days a week.

You may need to fully qualify the path to tar.

[edit]of course, do not forget to save the crontab![/edit]
Comments on this post
ishnid agrees!
__________________
According to Sod's Law, buttered toast lands butter side down, when dropped.
Per nature, cats always land on their feet.
So, what happens when you strap buttered toast to the back of a cat and throw it out a window?
.

Last edited by Ehlanna : July 12th, 2006 at 12:10 PM.

Reply With Quote
  #3  
Old July 13th, 2006, 04:02 AM
davidb2002's Avatar
davidb2002 davidb2002 is offline
Almighty God of Nothing
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Location: Rotherham, UK
Posts: 712 davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 6 h 35 m 41 sec
Reputation Power: 91
Send a message via ICQ to davidb2002
I know this may seem like a newb question as well but:

I type in "crontab -e" and i get a screen with a ~ on each line and I can't type anything.

Also, I noticed that there is nowhere to select save in the menus, so how do I do that also?

Sorry, im an extreme newb to all that is linux.

Reply With Quote
  #4  
Old July 13th, 2006, 02:47 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
Ok, we can do this!!!
The ~ chars are jusr 'placeholders' and show that there are no lines at all in the file you are editing (the crontab -e will automatically open up yoru cronfile). You are in the vi editor after typing crontab -e thus ...
press i (this will put you in insert mode)
type in the line for the command you wish to run.
Press the escape key (this will take you out of insert mode and back into 'command' mode).
type :wq (that will Write Quit your edit, saving the file - note that is the colon key followed by w then q, then you need to press enter.
All done!
Use crontab -l to just list the file to check it for correctness

Also, whilst we are here ... are you sure you want /dev/st0? Most tape operations take place against the raw device - /dev/rst0 in your case?

Reply With Quote
  #5  
Old July 13th, 2006, 02:48 PM
tj_nt tj_nt is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2004
Posts: 2,102 tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level)tj_nt User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 12 h 25 m 58 sec
Reputation Power: 1766

Reply With Quote
  #6  
Old July 14th, 2006, 02:51 AM
davidb2002's Avatar
davidb2002 davidb2002 is offline
Almighty God of Nothing
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Location: Rotherham, UK
Posts: 712 davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 6 h 35 m 41 sec
Reputation Power: 91
Send a message via ICQ to davidb2002
We had a programmer come in who knew a lot about linux to code customer management software for us. While he was here we asked him what do we need to do to create a backup on the the tape drive. He gave us that command. We have no coorispodance with him anymore as we decided not to use his software in the end. So thats why im here. If there is a better command for backing up the data on the machine let me know. I don't know the difference between the commands. Infact, i dont know anything about linux commands.

Reply With Quote
  #7  
Old July 14th, 2006, 11:50 AM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
Hmm, oh dear ...! Time to start reading

But let's get back on track:

Chuck a tape in the drive (I am hoping you have physical access!).
mt -f /dev/rst0 (should give some info - depending on OS you may need -t, not -f)
You may also want to try the /dev/st0 device file as well.

To test you can back (and restore!)
Create a dummy file:
Code:
mkdir -p /usr/test/backup
touch /usr/test/backup/testing
tar cvf /dev/rst0 /usr

(wait for tar to finish)
Code:
tar tvf /dev/rst0 | grep testing

(you should see the file you created with the touch command listed)
Code:
rm /usr/test/backup/testing
tar xvf /dev/rst0 /usr/test/backup/testing
(wait for tar to finish)
Code:
ls -l /usr/test/backup

(which should show you the file you recovered)

Reply With Quote
  #8  
Old August 2nd, 2006, 03:21 AM
davidb2002's Avatar
davidb2002 davidb2002 is offline
Almighty God of Nothing
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Location: Rotherham, UK
Posts: 712 davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 6 h 35 m 41 sec
Reputation Power: 91
Send a message via ICQ to davidb2002
Hi,

I have 2 questions:

How can I check to make sure that the backup was created successfully from the crontab?

How do I use this backup to restore (no use have a backup if you don't know how to use it)?

Thanks for the help so far.

Reply With Quote
  #9  
Old August 2nd, 2006, 11:15 AM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
* rolls up sleeves ....*
Okay, diving right on in ...

There are two ways, one following on from the other and building your confidence in your backup/recovery system.

First off, can we read the tar archive?

Code:
tar tvf /dev/rst0
or
tar tvf /dev/st0
depending on which you opted to use.

That will test the archive - t for test.

Assuming you see a long list of files being produced, along with owenserhip and size we know that the tape can be read and that it appears to have a viable archive upon it.

The real killer test is, of course, the "ooops, where did that flaming file go, dammit I will have to recover it" option. yes, it's test the recovery time!
Here is where it can get a little hairy, so bear with us!
The best thing to do is:
1) Create a dummy file in a directory that you are backing up.
2) Take a backup
3) Delete the file
4) Restore (or at least try to!) the file from the backup
Optional step 5) Gloat over re-appearance of recovered file and go get a beer!
Steps 1 to 3 should, I hope, not be beyond you.

Step 3 is the new one. Now, let us assume the following:

Code:
mkdir -p /usr/backuptest
echo "If this doesnt work I will be looking for a new job" > /usr/backuptest/backup.txt
tar cvf /dev/rst0 /usr
rm /usr/backuptest/backup.txt

(this is the new bit coming up ...)
Code:
tar xvf /dev/rst0 /usr/backuptest/backup.txt

Using the x for Extract option of tar

Now, having taken you all through that, I will pass on a little gem of wisdom ...

When backing up a system with tar use RELATIVE paths. That way you can recover the data to a new location and not be restricted to just over-writing any existing stuff.

Cheat sheet for backing up (for use in a script):
Code:
# Remember where we were
where=`pwd`
# change to where we want to backup, assuming single dir tree
cd /usr
# backup relative to here
tar cvf /dev/rst0 .
# remember return code for later testing 
cc=$?
# change dir back to where we were
cd $where


To recover, you 'just' need to be careful of what directory you are in and to remember to add a leading .
Thus the test above would be:
Code:
mkdir -p /usr/backuptest
echo "If this doesnt work I will be looking for a new job" > /usr/backuptest/backup.txt
cd /usr
tar cvf /dev/rst0 .
rm /usr/backuptest/backup.txt
cd /tmp
tar xvf /dev/rst0 ./usr/backuptest/backup.txt

And your file will now be in /tmp/backuptest.
Have fun!

Reply With Quote
  #10  
Old August 11th, 2006, 03:39 AM
davidb2002's Avatar
davidb2002 davidb2002 is offline
Almighty God of Nothing
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2005
Location: Rotherham, UK
Posts: 712 davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level)davidb2002 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 6 h 35 m 41 sec
Reputation Power: 91
Send a message via ICQ to davidb2002
Which command checks to make sure the file is on the tape?

Reply With Quote
  #11  
Old August 11th, 2006, 05:43 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 50 m 50 sec
Reputation Power: 1485
Use tar tf to list the tar file contents. If you have a particular file you are looking for pipe that through grep:

Code:
tar tf /dev/rst0 | grep "myfilename"

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Simple Cron Backup (Howto?)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap