Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-26-2013, 04:06 PM   #1
LQ Newbie
Registered: Nov 2013
Posts: 1

Rep: Reputation: Disabled
Copy latest files from linux to network drive

I have a linux server running an accounting package, I would like copy any files from that data directory that were altered each day to a network drive so it can be included in our backups.

Currently I am manually doing this each day by copy/paste between the directories. As I will be away from the business over christmas I need an icon staff can click on as they leave the office each day to run a script to do this.

I have extremely basic knowledge of any linux commands and my attempts to build a suitable script have so far failed completely.

The data drive path is: /u/pp/data

The target directory is svr-sbs1210/data/finance/share linux/copy/data

Any help would be fantastic, due to the size of the information I'd prefer to only copy file that changed the day the script is run rather than copy all files every day if possible.
Old 11-26-2013, 04:27 PM   #2
Senior Member
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,535

Rep: Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417Reputation: 1417
I suggest using rsync run as a cron job. e.g.
Old 11-26-2013, 04:29 PM   #3
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 613

Rep: Reputation: 142Reputation: 142
How's about...

rsync -r -a -v -t /u/pp/data svr-sbs1210/data/finance/share linux/copy/data
rsync copies only files which have changed.

-r recursive
-a archive mode (bascially, preserve all settings associated with the file on the original box)
-v verbose
-t the doco about this switch is limited. My take is that this means rsync preserves the date of the original file.
I have added my understanding of the switches. If anyone can improve on this pls do.

Test out the rsync command any time. Then you need to do a bit of digging regarding crontab to schedule the job to run every night - no need for manual intervention.
0 1 * * * /home/tim/cron/backup-docs
that is a job I run every day at 1am to backup my docs.

Old 11-26-2013, 04:39 PM   #4
Senior Member
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,845
Blog Entries: 36

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Originally Posted by timl View Post
rsync -r -a -v -t /u/pp/data svr-sbs1210/data/finance/share linux/copy/data
Your options are redundant and can be shortened. The -a option covers -r and -t already. So if you truly wanted the -v option then your command can be shortened to -a -v. Also, -a -v is the same as saying -av so in my opinion your command should look something like this.

rsync -av /u/pp/data svr-sbs1210/data/finance/share linux/copy/data
Though really since it's a cron job there's no need to see output if it is successful so -v is even unnecessary in my opinion.

In any case, I agree rsync is a good solution for the original poster.

Old 11-26-2013, 04:42 PM   #5
Registered: May 2001
Posts: 29,341
Blog Entries: 55

Rep: Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538
Originally Posted by timl View Post
I have added my understanding of the switches. If anyone can improve on this pls do.
Nothing to improve except the man page says "-a" means "-rlptgoD".

Test out the rsync command any time.
A good way could be to use "--dry-run --verbose --itemize-changes --stats" for testing (lots of output) and when running as a cron job add "--quiet --log-file=/var/log/rsync.log" to save output for review if necessary.
Old 11-26-2013, 05:20 PM   #6
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,083

Rep: Reputation: 862Reputation: 862Reputation: 862Reputation: 862Reputation: 862Reputation: 862Reputation: 862
i see there is a space in the directory name so it probably needs to be quoted (or escaped):
rsync -av /u/pp/data "svr-sbs1210/data/finance/share linux/copy/data"
- or -
rsync -av /u/pp/data svr-sbs1210/data/finance/share\ linux/copy/data

also if this goes in cron then it will need to know the full path of where the svr-sbs1210 subdirectory is located.


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 to copy files from a usb pen drive to my linux box? HelpMe2877 Linux - Newbie 4 08-20-2008 02:54 AM
I can't copy files into my D Drive carlsonultimate Linux - Newbie 10 10-12-2007 03:48 AM
Mepis, copy files to thumb drive, files deleted? vremenno Linux - Newbie 6 09-15-2006 11:21 PM
Cannot Copy Files From Network FAT32/NTFS Drive to My Local Linux Drive michaelh Linux - Networking 3 10-29-2002 10:27 AM

All times are GMT -5. The time now is 07:01 AM.

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