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 07-01-2011, 01:03 AM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.1 with Cinnamon & KDE
Posts: 1,478
Blog Entries: 3

Rep: Reputation: 95
want "xcopy /a" behavior from bash or similar


As I recall in the days of DOS and routine use of command.com,
the xcopy command had an option -- I think it was "/a".
When xcopy processed a file, it would alter the state of the archive attribute such that multiple runs of the same command would catch whatever was missed by the previous run. A common use was to fill diskettes and similar small storage media.
  • xcopy a group of files === rats, media full
  • xcopy catches more files === repeat ad lib
  • xcopy eventually catches the last remaining files

The gimmick is that as a file gets processed, it gets marked somehow so that it gets skipped on future runs.

How do I accomplish this sort of thing ?

~~~ 0;-Dan
 
Old 07-01-2011, 01:22 AM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Posts: 3,366
Blog Entries: 33

Rep: Reputation: 216Reputation: 216Reputation: 216
Hi, I used to use xcopy at uni to keep my flash-drive uptodate with my campus home folder.

Now with Linux I use rsync.

http://en.wikipedia.org/wiki/Rsync

I just found this tute, I hope it helps you too.
http://www.thegeekstuff.com/2010/09/...mand-examples/

Cheers Glenn
 
Old 07-15-2011, 07:41 PM   #3
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.1 with Cinnamon & KDE
Posts: 1,478
Blog Entries: 3

Original Poster
Rep: Reputation: 95
Thanks to all who mentioned rsync and similar. While the copy behavior is valuable and
Code:
prompt$ rsync -a ...
is extremely useful, the missing behavior involves the following:
  • start the file copy
  • somehow mark the files that get copied
    ... copy gets interrupted
  • start the file copy again
  • marked files get skipped this time

I can see that the timestamp aspects of rsync behavior might satisfy the requirement to copy
those files that were marked and missed. Specifically, if rsync wants to copy this time because
of the timestamp, it ought to want to copy after the interruption. Maybe someone can convince me
that this is as good or better than the xcopy -- unconditional copy if marked.

Thanks in advance,
~~~ 0;-Dan
 
Old 07-15-2011, 07:49 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Well ... the "problem" you're facing is that Linux' filesystems
have no notion of an "archive bit". So time-stamps + size really
are the only thing you can go by, unless you invent/write a
process by which you keep track of which files were successfully
copied by writing them out to a file, and reading that in on the
next run to make it skip automagically. rsync does a fabulous job,
alas it won't work too well if the target is a set of media
rather than one target directory structure.



Cheers,
Tink

Last edited by Tinkster; 07-15-2011 at 07:50 PM.
 
1 members found this post helpful.
Old 07-15-2011, 08:30 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
The unison file synchronizer system keeps track of previous syncs, and only propagates changes.

http://www.cis.upenn.edu/~bcpierce/unison/

Other backup/sync systems doubtlessly have similar features.
 
1 members found this post helpful.
Old 07-16-2011, 10:46 AM   #6
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.1 with Cinnamon & KDE
Posts: 1,478
Blog Entries: 3

Original Poster
Rep: Reputation: 95
Thanks to all -- for no other reason than you have helped me clarify the behavior that I seek.

1. Start a copy
2. some files succeed THIS time
3. re-start a copy
4. work on files that were not copied yet
5. some files succeed THIS (2nd) time
...
9. work on files that were not copied yet
10. all files finally succeed

I'll see what unison and rsync can do. Then, I'll report back.
~~~ 0;-Dan
 
Old 07-16-2011, 06:38 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
^ i think you would need some custom bash script. something like [untested]:
Code:
ls -1 /path/to/dir > /path/to/dest.lst
for item in `cat /path/to/dest.lst`
do
 cp $item /path/to/dest
 grep -v $item /path/to/dest.lst > /path/to/dest.lst
done
 
1 members found this post helpful.
Old 07-18-2011, 01:49 AM   #8
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Posts: 3,366
Blog Entries: 33

Rep: Reputation: 216Reputation: 216Reputation: 216
Hi, these are the commands I use frequently,

initial back up....

Quote:
rsync -avh /source/directory/ /copy/destination
subsequent back ups

warning, using the --delete switch will delete files not found in the source directory, if I remember correctly.

Quote:
rsync --delete -avh /source/directory/ /copy/destination
The only problems I have had is when the permissions have been wrong, but I only use it on local drives, not the network.

There could be other problems with that, like time-to-live, firewalls etc...

Hope this helps, Glenn
 
  


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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
C/C++ functions similar to BASH's "cp", "mv", "mkdir", etc? kornerr Programming 10 04-23-2006 10:48 AM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 11:43 AM


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