Bigbruin.com
Home :: Reviews & Articles ::
Forum :: Info :: :: Facebook :: Youtube :: RSS Feed
Search  :: Register :: Log in
Linux Help... Cron Jobs
Go To Page 1, 2  Next
Post new topic   Reply to topic    Bigbruin.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
Doctor Feelgood
Arrrrghh!


Joined: 07 Apr 2003
Posts: 20349
Location: New Jersey

PostPosted: Tue, 07 Dec 2004 21:15:28    Post Subject: Linux Help... Cron Jobs Reply with quote View Single Post

I am trying to setup automated backups of the site from the active hard drive to a backup drive I have installed.

It is currently doing it, but only creates three files... One that it over writes every night during a backup, one on a weekly basis, and one on a monthly basis.

I'd rather not lose the daily one so quickly, and would prefer to have a whole weeks worth of daily backups available. Currently I also make manual daily backups to my home machine, but would rather it all be automated, and online.

First... Help me understand the commands to make a gzip archive at the command line... Something like:

Quote:
tar c dir/ | gzip > dir.tar.gz


right? (please correct me).

how about to switch drives, using a symlink I have created? something like, for example:

Quote:
tar c home/dir/ | gzip > disk2/archive/dir.tar.gz


Confused

Now, once you have corrected my stuff above, how can I go about making it keep the last few backups like this?

Thanks Linux gurus! Sun


Last edited by Doctor Feelgood on Tue, 07 Dec 2004 21:37:24; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Little Bruin
Boo Boo

Joined: 07 Apr 2003
Posts: 667
Location: Pic-A-Nic Basket
IceNine
*The Freshest*


Joined: 08 Sep 2003
Posts: 1459
Location: Bel Air

PostPosted: Tue, 07 Dec 2004 21:19:28    Post Subject: Reply with quote View Single Post

You'll need a shell script that analyzes the dates for you. I would recommend having the date in the title - it keeps it simple that way. I'll see what I can come up with after I get home.
_________________

A letter to a soldier
Back to top
View user's profile Send private message
Doctor Feelgood
Arrrrghh!


Joined: 07 Apr 2003
Posts: 20349
Location: New Jersey

PostPosted: Tue, 07 Dec 2004 21:32:17    Post Subject: Reply with quote View Single Post

Wait, I see in my Cron Job info that I can not only set them to run every certain number of hours, days, etc... I can actually set them to run on certain days only.

Maybe then its just a matter of having a separate Cron Job for every day? Is that reasonable?

So... would my command above work?
Back to top
View user's profile Send private message Visit poster's website
BeerCheeze
*hick*


Joined: 14 Jun 2003
Posts: 9285
Location: At the Bar

PostPosted: Tue, 07 Dec 2004 21:34:10    Post Subject: Reply with quote View Single Post

Laughing I'll show this to Misty, she does this stuff all the time.
Back to top
View user's profile Send private message
misty
Mmmmm... Beer


Joined: 17 Jul 2003
Posts: 737
Location: In Dr. EvilCheeze's pants

PostPosted: Wed, 08 Dec 2004 14:40:22    Post Subject: Reply with quote View Single Post

You could always create a script that would append the date to the file name, something like.

#!/bin/ksh (where ever ksh is located)

FILENAME=dir.tar.`date +%m%d%Y`.gz

tar c dir/ | gzip > $FILENAME



I don't know much about gzip, so I can't tell you whether the syntax is right. I would set up one cron jobs to run daily using the script above so each job would have a different name. Then maybe also run a cleanup jobs that would find files older than 7 days and delete them.

_________________
Meg: Everybody! Guess what I am?
Stewie: Hm, the end result of a drunken back-seat grope-fest and a broken prophylactic?

Stewie: I was under the impression the name of the show was "Kids Say the Darndest Things," not "Old Black Comedians Never Shut the Hell Up."
Back to top
View user's profile Send private message Visit poster's website
misty
Mmmmm... Beer


Joined: 17 Jul 2003
Posts: 737
Location: In Dr. EvilCheeze's pants

PostPosted: Wed, 08 Dec 2004 15:23:41    Post Subject: Reply with quote View Single Post

Okay.. ignore me if you want to, but here's how you could make an archive.

#!/bin/ksh (where ever ksh is located)

FILENAME=dir.tar.`date +%m%d%Y`.tgz

tar -cvzf $FILENAME dir/

To write to another drive:

tar -cvzf $FILENAME /disk2/archive/$FILENAME



To cleanup your backups older than seven days you could run this script daily via cron.

find /dir/path -name "dir.tar*" -mtime +7 -exec rm {} ;

Something like that.. I think that will work, I just came up with it so it's never been tested.

_________________
Meg: Everybody! Guess what I am?
Stewie: Hm, the end result of a drunken back-seat grope-fest and a broken prophylactic?

Stewie: I was under the impression the name of the show was "Kids Say the Darndest Things," not "Old Black Comedians Never Shut the Hell Up."
Back to top
View user's profile Send private message Visit poster's website
misty
Mmmmm... Beer


Joined: 17 Jul 2003
Posts: 737
Location: In Dr. EvilCheeze's pants

PostPosted: Wed, 08 Dec 2004 15:36:53    Post Subject: Reply with quote View Single Post

To schedule stuff to run daily in cron at 10pm:

00 22 * * * /dir/path/command

minute hour day_of_month month weekday command

These fields accept the following values:

minute 0 through 59

hour 0 through 23

day_of_month 1 through 31

month 1 through 12

weekday 0 through 6 for Sunday through Saturday

command a shell command

_________________
Meg: Everybody! Guess what I am?
Stewie: Hm, the end result of a drunken back-seat grope-fest and a broken prophylactic?

Stewie: I was under the impression the name of the show was "Kids Say the Darndest Things," not "Old Black Comedians Never Shut the Hell Up."
Back to top
View user's profile Send private message Visit poster's website
Little Bruin
Boo Boo

Joined: 07 Apr 2003
Posts: 667
Location: Pic-A-Nic Basket
Doctor Feelgood
Arrrrghh!


Joined: 07 Apr 2003
Posts: 20349
Location: New Jersey

PostPosted: Wed, 08 Dec 2004 16:05:47    Post Subject: Reply with quote View Single Post

Whoa... Thanks! I'll try something once I process all of that! Yikes
Back to top
View user's profile Send private message Visit poster's website
BeerCheeze
*hick*


Joined: 14 Jun 2003
Posts: 9285
Location: At the Bar

PostPosted: Wed, 08 Dec 2004 18:20:44    Post Subject: Reply with quote View Single Post

Great huh? I'm married to a Unix geek... Laughing
Back to top
View user's profile Send private message
Doctor Feelgood
Arrrrghh!


Joined: 07 Apr 2003
Posts: 20349
Location: New Jersey

PostPosted: Wed, 08 Dec 2004 19:26:06    Post Subject: Reply with quote View Single Post

I think I got it. I set up one to take just the public_html area of the site and gzip over onto the second drive at 5 PM on Wednesdays only.

Just got home and see I have a 160MB file with the proper name right where I wanted it! Grin

Thanks!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Bigbruin.com Forum Index -> Software All times are GMT - 4 Hours
Go To Page 1, 2  Next
Page 1 of 2

 
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
Contact Us :: On Facebook :: On Youtube :: Newsletter :: RSS Feed :: FAQ :: Links :: Sponsors :: Privacy Policy
Copyright © 2000 - 2023 Bigbruin.com - All rights reserved