Solved

Fedora 5 Backup to usb hard drive

Posted on 2006-10-30
8
160 Views
Last Modified: 2013-12-16
Hello EE.  I have a linux box, providing file services, firewall and proxy.  setup with help from many of you (thanks)
What I want to do is backup the /data partition (samba)  to a usb drive which is permanently attached and then shut down the machine daily at 7pm.  So basically I have a folder on the driver  which is at /media/sea_disk/Backups

I would like the daily backup to only backup what has changed.  And then on saturday do a complete backup to the same location.

And then shut down the machine.  


0
Comment
Question by:aduhwale
  • 4
  • 3
8 Comments
 
LVL 14

Accepted Solution

by:
ygoutham earned 250 total points
ID: 17840408
for the daily backup, you can try rsync

rsync -avz --delete /data/* /media/sea_disk/Backups/

please note that the --delete is only an option if you want the target files to be deleted as well. remove it if you want to retrieve any deleted files that a user might request for (which happens at all time with me :-)

for a weekly backup, just to a

cp -Rp /data/* /media/sea_disk/Backups/  

the weekly backup and daily backup can be run through the crontab.

do a

crontab -e (as root)

01 0 * * * (your rsync command here)

and for weekly backup

01 0 * * 6 (your cp command here)

the weekly would run on mondays at the change of system clock date.   the hour can be any 24 hour format to run at a specified time.

by shutdown the machine are you stating that the machine should be powered off??? or only the usb drive to unmounted???

you can also put the same in a bash script and run it as a script at an appointed hour ending with

'shutdown -h -t 5 "an optional message here"   ' (without the initial and end single quote) at the end of the script to tell the machine to shutdown after finishing the rsync/ cp command.

goutham
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 17840411
sorry the weekly command is to run on saturdays (number 6 in crontab entry is right) but monday is wrong

: - (
0
 
LVL 2

Author Comment

by:aduhwale
ID: 18094972
Hi ygoutham , wasnt ignoring you.  Got side tracked with another project.   I am testing this saturday and will then confirm i am successfull.

Regards

Adewale
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 2

Author Comment

by:aduhwale
ID: 18198503
Thanks   ygoutham.    This worked great.  I only need help figuring out where to put the shut down command.  do i put it on the same line as the cp command.
0
 
LVL 2

Author Comment

by:aduhwale
ID: 18198545
in crontab I mean - how do you I get it to point to a script?
Thanks again.
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 18198587
in crontab you have five fields

01 13 * * * sh /path/to/some/script.sh

the above line means to execute a script called script.sh which is a shell script at 13:01 hours every day.  read more on

man 5 crontab
man crontab

to shutdown a machine

shutdown -h -t 5 now

this means to shutdown the machine in 5 seconds from now and halt the system.  the same command can also go into your crontab.  but shutdown is not given enough rights to be run from crontab.  just check on the first before adding the same.  just look at /etc/sudoer
0
 
LVL 2

Author Comment

by:aduhwale
ID: 18201166
Hey.  Thanks!  
I hadnt actually written a script before.  now i have - albeit a simple one.    I am tinkering with the timings but I am good to go.

Thanks again.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question