Solved

Fedora 5 Backup to usb hard drive

Posted on 2006-10-30
8
155 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now