LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-26-2013, 05:06 PM   #1
evang
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, 05:27 PM   #2
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,429

Rep: Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348Reputation: 1348
I suggest using rsync run as a cron job. e.g. http://www.marksanborn.net/howto/use...nthly-backups/
 
Old 11-26-2013, 05:29 PM   #3
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 581

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

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

Quote:
-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.
Quote:
0 1 * * * /home/tim/cron/backup-docs
that is a job I run every day at 1am to backup my docs.

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

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
Quote:
Originally Posted by timl View Post
Code:
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.

Code:
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.

SAM
 
Old 11-26-2013, 05:42 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
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".


Quote:
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, 06:20 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
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.
 
  


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


All times are GMT -5. The time now is 04:46 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