LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-30-2004, 11:31 AM   #1
robhargreaves
Member
 
Registered: Dec 2003
Location: UK
Distribution: Slackware
Posts: 87

Rep: Reputation: 15
Question Backup setup


One thing I would like to be able to do is to set up my pc to back up automatically for me all of the files I have in my /opt/ directory and add them to my other hard disk on a partition I will create called backup. I will call the partition backup so it will be at /usr/backup

I have been putting programs in here before they have been compiled onto the system. I have created a directory called system here too. I use this to keep in my files downloaded such as kernel sources previously downloaded and files for the system from intel, creative soundblaster drivers.

If I have got quite a bit of room on the drive is it a good idea to backup some of my other os files too?? which ones do you recommend I add to this backup?

I believe i should be using cron or the crontabs is that true?? If so which one? bearing in mind I have got KDE3.1, Slack 9.1.

Thanks guys for the help it will be a thinhg off my mind if I can automate backups of my data like I used to do in windows.

Rob
 
Old 01-30-2004, 11:35 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Here is an example setup which I have......

Creating a cron job to backup the /home directory every day at 11:00pm.

mkdir -p /mnt/backup
mount /dev/hdb1 /mnt/backup -t ext3

Add a line to fstab to mount it everytime you boot.
/dev/hdb1 /mnt/backup ext3 defaults 0 0

Make a file called /mnt/backup/backup.job
#!/bin/bash
filename=`date '+%m%d%y'`
tar -cvzf /mnt/backup/${filename}.tar.gz /home

Run these commands:
chmod +x /mnt/backup/backup.job
export EDITOR=vi
crontab /etc/crontab
crontab -e

Add a line to your personal crontab.....
00 23 * * * /mnt/backup/backup.job

Save the changes with the command: :wq!
 
Old 01-30-2004, 12:28 PM   #3
robhargreaves
Member
 
Registered: Dec 2003
Location: UK
Distribution: Slackware
Posts: 87

Original Poster
Rep: Reputation: 15
Thanks Homey I will give it a shot

you said -

Make a file called /mnt/backup/backup.job
#!/bin/bash
filename=`date '+%m%d%y'`
tar -cvzf /mnt/backup/${filename}.tar.gz /home

What are variables for filename = (the syntax for hostname,time etc)

Run these commands:
chmod +x /mnt/backup/backup.job
export EDITOR=vi
crontab /etc/crontab
crontab -e

What are you doing in lines 3-5 here?

Add a line to your personal crontab.....
00 23 * * * /mnt/backup/backup.job

I guess 00 06 * * * /mnt/backup/backup.job

is for 6am but what are the other 00's and ***'s for and where is my personal crontab? cron.daily, cron.monthly? etc
 
Old 01-30-2004, 01:04 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
filename=`date '+%m%d%y'
This gives the current date to the filename so you can keep track of them.

chmod +x /mnt/backup/backup.job
This makes the backup.job executable so cron can run it.

export EDITOR=vi
crontab /etc/crontab
crontab -e
This just makes it automatically open the vi editor when you make the next statement. You only need to do this when setting it up.

I guess 00 06 * * * /mnt/backup/backup.job

Yep, that's for 6am and "00" is for no minutes. If you had a * in the minutes column, the job would run every minute of the 6am hour.

"is for 6am but what are the other 00's and ***'s for and where is my personal crontab? cron.daily, cron.monthly? etc"

The other *'s are for day, week and month
This just one way of doing things, as usual in Linux, you can use other methods. One is to put the script into the /etc/cron.hour folder and then edit the /etc/crontab to include the 06 line.
You also can set it up using Webmin.

Last edited by homey; 01-30-2004 at 01:11 PM.
 
Old 01-30-2004, 01:17 PM   #5
robhargreaves
Member
 
Registered: Dec 2003
Location: UK
Distribution: Slackware
Posts: 87

Original Poster
Rep: Reputation: 15
I see. It is much faster to just use the ***'s to specify when you want the jobs doing then you dont have to mess about with the other cron folders.
 
Old 01-30-2004, 01:24 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Yep, that just says to run the job at

00 Minutes, 6am hour, every day, every week and every month.
 
Old 10-19-2006, 05:16 PM   #7
bax
Member
 
Registered: Dec 2001
Location: NoVA
Distribution: Ubuntu, Solaris, OpenBSD
Posts: 492

Rep: Reputation: 30
I know this is an old thread but I'd hate to start a new one. How do i setup this up to overwrite each previous backup?
 
Old 10-19-2006, 05:29 PM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by bax
I know this is an old thread but I'd hate to start a new one. How do i setup this up to overwrite each previous backup?
Well if you place these in their own directory, just add a rm -rf /path/to/file.tar.gz

Or why not keep an actual retention of a week with something like:

find /path/to/*.tar.gz -t file -mtime +7 -exec rm -rf {} \;
 
Old 10-19-2006, 05:32 PM   #9
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Don't mount your backup directory in /usr. /usr is for read-only data according to the filesystem hierarchy standard.

If you only temporarily mount the device (i.e. while making or restoring from backups), mount it at /mnt, Else the proper place is probably /var/backups.
 
  


Reply


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
How do I make a backup .iso of my setup? Charos MEPIS 16 08-28-2005 04:01 PM
How do I setup an auto backup to an email address? glenn69 Linux - General 5 10-10-2004 06:26 AM
how to setup a backup server for a samba PDC kenji1903 Linux - Networking 3 04-26-2004 11:54 PM
Help Pls Setup backup and Tape drive kesh Linux - Newbie 0 04-21-2004 09:18 AM
squid issues or what? - LAN backup server setup problem htm Linux - Networking 2 03-18-2004 09:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:46 AM.

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