Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
By shane25119 at 2009-02-11 23:55
Data is valuable and making backups is a great idea. Unfortunately, backing up is time consuming, so it makes great sense to have a script do it for you. Rsync is the undisputed favorite script for this task.
However, there is a bug in rsync that causes it to completely mangle timestamps on some systems, everything I have read suggest it is a Nautilus problem. This is a work around to allow you to automatically backup to a network harddrive if you run into rsync's timestamp problems.
This guide is written for Ubuntu, but can easily be adapted to any distribution.
First off, hook up your network hard drive and configure it (i.e. set passwords, name it, etc).
Next, create a mount point for our network drive- from the command prompt:
sudo mkdir /media/network_drive
Of course, you can call it anything you want, network_drive, backup, lollipops etc.
I prefer to only mount my network drive while in use; so, I begin my script by mounting the drive: (Please note, the echos are not strictly speaking needed, I just like to know what's going on).
In the above code, //192.168.0.11/backup represents first the IP address of the network hard drive on the network, and then the topmost directory there in.
$USER represents the username you have set for your network drive
$PASSWORD is, you guessed it, the password for your network drive
$ROOT_PASSWORD is the system's root password, you don't have to enter this, but if you don't you will have to enter the root password everytime the script runs before it can go onward.
Next up, we'll start backing things up.
Now, normally, we'd launch straight into rsync and just be done with it. But since goofed up time stamps can totally mess up any backup scheme we're going to use a hybrid of rsync and cp.
Since we want a copy of what's on our computer we should make sure the network drive and the local drive are the same. So, we're going to have rsync compare the local drive to the network drive and delete the files on the network drive that are not on the local drive. For this example, we're going to use my documents folder:
/home/shane/docs is my documents folder, the source.
/media/network_drive/docs/ is my backup, the destination.
-r stands for recursive, this tells rsync to go down into folders to look.
--delete tells it to delete excess files on the destination.
After that's done, we're going to go ahead and backup:
cp -aupr /home/shane/docs /media/network_drive/
-a stands for archieve, to create a backup.
-u stands for update, this way we'll only be copying files which are newer on the source (our local drive and leave the other files alone).
-r stands for recursive, this tells cp to go down into the folders.
-p is preserve, this makes sure the timestamps stay the same across both the local drive and the network drive.
You can repeat this as many times as you need to with as many different directories as you
Once you're all done you need to take the network drive down: