View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-04-2006, 09:42 PM   #1
LQ Newbie
Registered: Dec 2005
Distribution: Fedora Core 4
Posts: 12

Rep: Reputation: 0
How to make a scheduled backup using cron file?

Im using Fedora Core 4 and Im wondering if anyone know how to make a scheduled backup using cron file?

Please inform me as soon as possible.

Thanks in advance.
Old 02-04-2006, 10:18 PM   #2
Senior Member
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Ubuntu, FreeBSD
Posts: 1,449

Rep: Reputation: 47
Make a script to perform the backup and then call it from your crontab.

Here is an example from my system. I dump the filesystem(s) I want across the network to a fileserver. I use ssh to do this. This example probably will not work for you... it is an example. Either modify it for your site or create a whole new model on for your own needs.

Backup script: dump.sched


perfdump() {
        for file in $FILESYSTEMS
                echo "Dumping ${file}: /dev/$file to ${backuphost}:$DUMPFILE"
                dump -${LEVEL}Lau -h 0 -f - /dev/$file | gzip -2 |ssh ${backupuser}@${backuphost} dd of=$DUMPFILE

dayofmonth=`date | awk 'BEGIN{FS=" "}{print $3}' -`
if [ dayofmonth = "1" ] ;then
        case `date | awk 'BEGIN{FS=" "}{print $1}' -` in
                Sat)    LEVEL="9"
                Sun)    LEVEL="9"
                Mon)    LEVEL="9"
                Tue)    LEVEL="9"
                Wed)    LEVEL="9"
                Thu)    LEVEL="9"
                Fri)    LEVEL="5"
                        NUMBER=`dc << END
                                $dayofmonth 1-7/pq
                *)      echo "Error: something went wrong with the date!"
                        exit 1

Crontab entry
23      4       *       *       *   /root/bin/dump.sched
At 4:23 each morning this script performs the backup for me.

Edit: Wow, it's been a long time since I looked at that script. It could probably be done in a much better manner now. I didn't write it to be the best example of a script -- I just needed something to work.

Last edited by frob23; 02-04-2006 at 10:22 PM.
Old 02-04-2006, 10:51 PM   #3
LQ Newbie
Registered: Dec 2005
Distribution: Fedora Core 4
Posts: 12

Original Poster
Rep: Reputation: 0
Im sorry for asking this. But im a newbie you see, so if you dont mind me asking, where exactly do i have to type
Backup script: dump.sched
Crontab entry
? Is it in the text editor like gEdit? or the terminal?

One more thing, which part of the script exactly that do i have to change?

Sorry if my question seems a lil bit silly to you...
Old 02-04-2006, 11:23 PM   #4
Senior Member
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Ubuntu, FreeBSD
Posts: 1,449

Rep: Reputation: 47
You type the contents of the code-box for dump.sched into a file and save it as dump.sched.

You use "crontab -e" to add the other line to your crontab.

What you need to change depends on how you are doing to perform your backups, to what media, what partitions and filesystems, and according to what schedule.

The above script dumps one freebsd partition across a network onto a fileserver. It does a complete backup once a month. A weekly backup each Friday (everything which changed during the week). And a nightly backup every day (but Friday and the 1st of the month) which backs up everything which changed in the last 24 hours.

This is probably a more complex backup schedule than you need and would want to deal with in a restore situation. It is impossible for me to guess what your backup needs are.

What do you need to backup?
What method do you prefer to backup everything?
How often do you want to back things up?
Where are you backing things up to?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron - doesn't seem to run scheduled tasks robintw Linux - General 11 11-25-2005 01:53 AM
What does cron do if machine is down when job is scheduled? Utah Linux - Software 4 08-24-2005 07:23 PM
creating a cron(tab) scheduled thing student04 Linux - Software 5 12-26-2004 09:18 PM
is there anyway to make linux turn on at a scheduled time? jontyrhodes Linux - General 2 06-04-2004 01:04 PM
Can I make a Cron job to synch/transfer a file from a folder to another FTP?... read efishta Linux - General 6 07-19-2003 10:03 PM

All times are GMT -5. The time now is 04:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration