LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-14-2009, 02:26 PM   #16
shane25119
Member
 
Registered: Aug 2003
Location: Illinois
Distribution: Linux Mint XFCE
Posts: 647

Rep: Reputation: 52

I've had the same problem a few months ago... this was my work around:::

Quote:
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:

Code:

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).

Code:

#!/bin/bash
echo "Remote Backup Script- Docs"

echo "Mounting Remote Drive"

sudo mount -t cifs //192.168.0.11/backup /media/network_drive -o username=$USER,password=$PASSWORD,uid=$USER
password=$ROOT_PASSWORD

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:

Code:

rsync -r --delete /home/shane/docs/ /media/network_drive/docs/

/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:

Code:

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
like.


Once you're all done you need to take the network drive down:

Code:

echo "Unmounting Network Drive..."
sudo umount /media/network_drive

Of course, make sure to change 'network_drive' to whatever you called your network drive.


Go ahead and save the file, now it is time to set it's permissions so it can be executed by a regular user:::

From the command line

Code:

chown root yourscript
chmod 4755 yourscript

yourscript- is whatever you named the script, make sure you change the command prompt's directory to whereever the script is at.

Next up, we'll set how often you want it to run. This we can do from a graphical interface in GNOME.

That tutorial has been written already, and it is here: https://help.ubuntu.com/community/CronHowto

For some reason, gnome-schedule was not on my start-menu, so I just used the run command to start 'scheduled-tasks'.
 
Old 07-15-2009, 03:46 PM   #17
jraclarke
Member
 
Registered: May 2006
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32

Original Poster
Rep: Reputation: 15
Thanks for that. That does seem to work one way (from my external HD to my desktop) but not the other way round (it simply copies all the files over again not just the updated ones). My thought is that maybe it's something to do with the VFAT filesystem that both rsync and cp -aupr don't like.

I'm actually trying to create an ext3 partition on the drive for my work data from linux. Partition magic is coming up with an error when it tries to split the partition, so my guess is also that there's some issues that need repairing on the HD also. I'm just looking into this now!

Cheers

James
 
Old 07-30-2009, 07:23 AM   #18
jraclarke
Member
 
Registered: May 2006
Location: Farnham, Surrey, UK (Chile until Dec 2011)
Distribution: Fedora Core 14
Posts: 32

Original Poster
Rep: Reputation: 15
Just to finalise this thread. I backed up all my data and attempted to partition with live gparted. It seemed to be running ok, however I left it for 24 hours and it still hadn't finished. I decided to cancel the process, reformatted the drive with partition magic and then partitioned to Ext3 and VFAT (this time much quicker). I think that gparted is very slow when partitioning large drives that contain data! Anyway now I back up my linux data to the Ext3 and there are no problems with permissions/time stamps at all (either with rsync or cp -aupr).

Many thanks for everyones' help.

James
 
  


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
external firewire hard drive is read only roofninja Ubuntu 5 02-16-2008 04:41 PM
External hard-drive - readonly, can't make it read/write mooseman Linux - Hardware 3 05-18-2007 03:27 AM
New External Hard drive is Detected As Read-Only tubatodd Ubuntu 2 02-11-2007 01:19 PM
Can't read external hard drive alrymala Linux - Security 1 10-23-2005 02:42 PM
read external hard drive mccclxxxv Linux - Hardware 4 04-21-2004 07:15 PM


All times are GMT -5. The time now is 12:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration