This is a discussion on Script to Copy Files Conditionally within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> Hi i need a short script to copy files from one drive to an archive drive. Have been using ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi i need a short script to copy files from one drive to an archive drive. Have been using cmds like cp -pfR from one drive to another, but it would be more efficient if the copy were conditional on the date / time difference between source / destination file. Have been looknig for a way to do this, but am no script expert and any pointers to relevant commands or examples would be appreciated... Chris ---------------------- Greenfield Designs Ltd Electronic and Embedded System Design Oxford, England (44) 1865 750 681 |
| |||
| On Wed, 04 Apr 2007 16:21:08 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: > i need a short script to copy files from one drive to an archive > drive. Have been using cmds like cp -pfR from one drive to another, > but it would be more efficient if the copy were conditional on the > date / time difference between source / destination file. > > Have been looknig for a way to do this, but am no script expert and > any pointers to relevant commands or examples would be appreciated... rsync |
| |||
| Frank Cusack wrote: > On Wed, 04 Apr 2007 16:21:08 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: > >>i need a short script to copy files from one drive to an archive >>drive. Have been using cmds like cp -pfR from one drive to another, >>but it would be more efficient if the copy were conditional on the >>date / time difference between source / destination file. >> >>Have been looknig for a way to do this, but am no script expert and >>any pointers to relevant commands or examples would be appreciated... > > > rsync Thanks. Just looked at that and will probably build and have a look, but really only need to mirror files on the same machine. A cron driven script would be more appropriate in this case... Chris -- ---------------------- Greenfield Designs Ltd Electronic and Embedded System Design Oxford, England (44) 1865 750 681 |
| |||
| On Wed, 04 Apr 2007 17:15:39 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: > Frank Cusack wrote: >> On Wed, 04 Apr 2007 16:21:08 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: >> >>>i need a short script to copy files from one drive to an archive >>>drive. Have been using cmds like cp -pfR from one drive to another, >>>but it would be more efficient if the copy were conditional on the >>>date / time difference between source / destination file. >>> >>>Have been looknig for a way to do this, but am no script expert and >>>any pointers to relevant commands or examples would be appreciated... >> >> >> rsync > > Thanks. Just looked at that and will probably build and have a look, > but really only need to mirror files on the same machine. A cron > driven script would be more appropriate in this case... 0 0 * * * rsync src dst -frank |
| |||
| Frank Cusack wrote: > On Wed, 04 Apr 2007 17:15:39 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: > >>Frank Cusack wrote: >> >>>On Wed, 04 Apr 2007 16:21:08 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: >>> >>> >>>>i need a short script to copy files from one drive to an archive >>>>drive. Have been using cmds like cp -pfR from one drive to another, >>>>but it would be more efficient if the copy were conditional on the >>>>date / time difference between source / destination file. >>>> >>>>Have been looknig for a way to do this, but am no script expert and >>>>any pointers to relevant commands or examples would be appreciated... >>> >>> >>>rsync >> >>Thanks. Just looked at that and will probably build and have a look, >>but really only need to mirror files on the same machine. A cron >>driven script would be more appropriate in this case... > > > 0 0 * * * rsync src dst > > -frank Thanks, but it's still overkill, when a one or two line script would probably get the job done just as well :-). What happened to all the arcane skills of unix, a single tool to do a single job well, specialisation over generalisation etc, or has it all morphed into the bloatware that is modern Linux ?... Chris -- ---------------------- Greenfield Designs Ltd Electronic and Embedded System Design Oxford, England (44) 1865 750 681 |
| |||
| On Wed, 04 Apr 2007 18:14:56 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: > Frank Cusack wrote: >> On Wed, 04 Apr 2007 17:15:39 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: >> >>>Frank Cusack wrote: >>> >>>>On Wed, 04 Apr 2007 16:21:08 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: >>>> >>>> >>>>>i need a short script to copy files from one drive to an archive >>>>>drive. Have been using cmds like cp -pfR from one drive to another, >>>>>but it would be more efficient if the copy were conditional on the >>>>>date / time difference between source / destination file. >>>>> >>>>>Have been looknig for a way to do this, but am no script expert and >>>>>any pointers to relevant commands or examples would be appreciated... >>>> >>>> >>>>rsync >>> >>>Thanks. Just looked at that and will probably build and have a look, >>>but really only need to mirror files on the same machine. A cron >>>driven script would be more appropriate in this case... >> >> >> 0 0 * * * rsync src dst >> >> -frank > > Thanks, but it's still overkill, when a one or two line script would > probably get the job done just as well :-). You may have lost me here. How is a 1 or 2 line script LESS work or LESS overkill than a single line cron entry. Here's your one line script: --8<--- #!/bin/sh rsync $1 $2 --8<--- Or does the smiley indicate you are joking? > What happened to all the arcane skills of unix, a single tool to do a > single job well, specialisation over generalisation etc, or has it all > morphed into the bloatware that is modern Linux ?... You've really lost me there. rsync is a single tool that does its single highly specialized job quite well. -frank |
| |||
| Frank Cusack wrote: > > You've really lost me there. rsync is a single tool that does its > single highly specialized job quite well. > > -frank Not a windup, just the gut feeling that Solaris probably already has scriptable commands that would do such a simple job. Just looking for a solution that doesn't involve installing yet more software with attendant demons etc. If there isn't such a solution, then rsync does look like the way forward... Chris ---------------------- Greenfield Designs Ltd Electronic and Embedded System Design Oxford, England (44) 1865 750 681 |
| |||
| On Wed, 04 Apr 2007 21:41:41 GMT ChrisQuayle <nospam@devnul.co.uk> wrote: > Frank Cusack wrote: > >> >> You've really lost me there. rsync is a single tool that does its >> single highly specialized job quite well. >> >> -frank > > Not a windup, just the gut feeling that Solaris probably already has > scriptable commands that would do such a simple job. It does. I was just giving you the easiest possible method. > Just looking for a solution that doesn't involve installing yet more > software with attendant demons etc. rsync doesn't need any daemon, etc., but I agree installing ever more and more software is a PITA for smaller shops. rsync is a standard tool, Solaris is deficient for not having it by default. > If there isn't such a solution, then rsync does look like the way forward... rsync is much easier, and much more efficient than any other method. One example of how to do it with the built-in tools: (cd src && find . -depth) | cpio -pdm dst but then you have to do some moderate post-processing (on the output from cpio) to exclude error messages about not copying files that are already newer (while still reporting other errors). If you have GNU tar (same problem with rsync though, you need addt'l software), you can use the --newer option to get pretty close to what rsync would do. -frank |
| |||
| On 2007-04-04 22:41:41 +0100, ChrisQuayle <nospam@devnul.co.uk> said: > Not a windup, just the gut feeling that Solaris probably already has > scriptable commands that would do such a simple job. Just looking for a > solution that doesn't involve installing yet more software with > attendant demons etc. rsync ships as a package on the Solaris 10 software companion. I'm not sure about earlier releases, but if it's not on the companion CDs there are undoubtedly packages at sunfreeware. There's no daemon (you can run rsync as a daemon but you don't need to and no daemon is set up by default). > > If there isn't such a solution, then rsync does look like the way forward... It's a fantastically useful tool for mirroring things. |
| ||||
| On 2007-04-05, Tim Bradshaw <tfb@tfeb.org> wrote: > On 2007-04-04 22:41:41 +0100, ChrisQuayle <nospam@devnul.co.uk> said: > >> Not a windup, just the gut feeling that Solaris probably already has >> scriptable commands that would do such a simple job. Just looking for a >> solution that doesn't involve installing yet more software with >> attendant demons etc. man find Look at the time related, -exec & -cpio options. > > rsync ships as a package on the Solaris 10 software companion. I'm not > sure about earlier releases, but if it's not on the companion CDs there > are undoubtedly packages at sunfreeware. pkg-get install rsync Not hard ... -- Ignorance more frequently begets confidence than does knowledge: it is those who know little, not those who know much, who so positively assert that this or that problem will never be solved by science. [email me at huge {at} huge (dot) org <dot> uk] |