Re: sending selected files to remote machine (NOT an incremental backup!)

From: Douglas Mayne (doug_at_slackware-3.localnet)
Date: 11/27/04


Date: Sat, 27 Nov 2004 11:10:35 -0700

On Sat, 27 Nov 2004 08:53:57 -0800, Casey wrote:

> I want to be able to send all recently modified files to a remote
> server. I DON'T mean an incremental backup! In fact this isn't
> really a backup scenario at all. I have two big discs at home,
> one for backup, but only a limited amount of space on my work
> machine. I just want to be able to send the files I have worked
> on at home in the last 24 hours (say) across, preferably with a
> single command, maintaining the dir structure (so that my aliases
> and so on will work identically on them, and to avoid problems
> with same name files in different dirs).
A single command can combine multiple commands into a single executable
script.
>
> Here's what I envisage:
>
> 1. Identify the recent work files:
>
> find / -mtime -2 -print
>
> (In fact, it'll only be searching through a list of dirs.)
>
> 2. Send them to the remote machine, preserving the dir structure (and
> attributes). This is where the problem is.
>
> Why not use rsync? AFAIK, rsync can be set to take just files which
> match a pattern, but can't be set to take files by mtime (or other
> attributes).
So what? Use "find" to select, and the --files-from option.
>
> Why not use ncftp? Again afaik, ncftp will send dirs recursively but not
> selecting by mtime.
>
> It occured to me to use command line ncftpput for each file
> individually, but that seems heavy-handed. (Am I wrong?)
>
> Thanks in advance ...
>
Note: part of response inline.

First, identify files you want to send. Choose some method which meets
your criteria. You can experiment with "find" until the selection
matches your criteria exactly. Save your selected files to a temp
file. Then employ one the two methods listed below.

First method: rsync

rsync will still work when you aren't running an rsync server using ssh
transport. The sshd daemon needs to be running and the user syntax is a
bit different- there are no "modules" per se. Just use a single colon to
separate the machine name.

CAUTION: rsync is powerful and can overwrite directories. Be careful with
it while you are testing. Experiment with directories where you can limit
the damage until you have it down pat. It is picky about trailing slashes
and dots on pathnames, so make sure you are clear about your intended
source and destination before starting rsync. Obviously, the --delete
option can be dangerous. The command is very useful! Verify my commands
below will work for you- hopefully, there are no typos.

To push a list of files to a remote destination:

REMOTE_DEST=somebox.somewhere.com:/home/someone/somedir
(cd $START_DIR &&
rsync -lptrv --progress --files-from=/tmp/some_list . $REMOTE_DEST)

Second method (if rsync is inadequate): tar and scp.

Identify files as before, then build a tar archive:

        (cd $START_DIR &&
        tar -cpf - -T /tmp/some_list | gzip) >~/to_send.tgz

Then send to remote machine:
        scp ~/to_send.tgz $REMOTE_DEST

Finally, expand the archive at the destination computer. Left as
an exercise for you ;-)

Final Note:
To meet your requirement of a single command, you can combine the commands
into an executable script. Parts of this problem are suitable for
automatic time of day execution (command: "at"). Other parts of the
problem are trickier- I haven't solved the problem of ssh authentication
to work automatically via a time of day script.

-- 
Dr. Strangelove: Based on the findings of the report, 
my conclusion was that this idea was not a practical deterrent
for reasons which at this moment must be all too obvious.
http://us.imdb.com/title/tt0057012/quotes


Relevant Pages

  • Re: Backup Image for my needs
    ... I will store on windows box connected ... My backup consists of just copying the 'files' to a backup medium ... Here are two links on how to create backups with rsync. ... type 'man command' on the command line. ...
    (Debian-User)
  • rsync backup size
    ... I run rsync with the command: ... to back up to a usb hard drive that already had a full backup on it. ... This appears to happen with no special command option. ... If it's the target, it means there was no compression. ...
    (Ubuntu)
  • [SLE] Can anyone recommed a backup program/script for home user
    ... Would like to thank Bruce for a detailed instruction to do backup. ... Now I will write a little script containing this command and when req just ... > also have success with rsync. ... -e ssh to use ssh to do the connection. ...
    (SuSE)
  • Re: [SLE] Can anyone recommed a backup program/script for home user
    ... I use this script to backup my laptop to my other boxes, ... >Now I will write a little script containing this command and when req just ... >>also have success with rsync. ...
    (SuSE)
  • Re: Windows could not start because the following file is missing or corrupt: System32DriversNtfs.sy
    ... Backup a bad filesystem and the Backup maybe worthless, ... Using the F10 option, once you get to the C: prompt, put the floppy in ... and see if ntfs.sys file is on the floppy ... Alt and D keys at the same time to go to a command prompt. ...
    (microsoft.public.windowsxp.general)