Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rsync using --backup-dir=

314 views
Skip to first unread message

Ralf S. Hellersen

unread,
Mar 28, 2014, 11:56:38 AM3/28/14
to
Hello rsync users !

I would like to perform on my machine (192.168.2.100) the following
process in order to get rid of the files on computer 192.168.2.103, but
to have them moved and collected for further analyses in directory ~/old
on the (remote) machine 192.168.2.103.

# rsync --delete -av --progress /dat/Musik_Originale/ ro...@192.168.2.103:/
dat/Musik_Originale/ --backup-dir=~/old ;

The process is starting, deleting files, but the directory ~/old remains
allways empty. This is not wanted.

Creating a directory ~/old on machine 192.168.2.100 results either in an
empty directory. Nor /dat/Musik_Originale/old neither /dat/old or
even /home/a_user/old (on both computers) contained the wanted data.

My search in different sources was not successfull, but I know
there must be a solution.

My questions are, did I use the correct syntax and where is the mistake ?
Where could I create this directory ~/old precisly ?


Regards
Ralf



--
Wegen SPAM: Für e-mail verwenden: "errr" statt "erxr" oder mein Kontakt-
Formular auf www.pis-db.de !

Dave Sines

unread,
Mar 28, 2014, 12:52:02 PM3/28/14
to
Ralf S. Hellersen <schne...@arcor.de> wrote:
> Hello rsync users !
>
> I would like to perform on my machine (192.168.2.100) the following
> process in order to get rid of the files on computer 192.168.2.103,
> but to have them moved and collected for further analyses in
> directory ~/old on the (remote) machine 192.168.2.103.
>
> # rsync --delete -av --progress /dat/Musik_Originale/ ro...@192.168.2.103:/
> dat/Musik_Originale/ --backup-dir=~/old ;

The --backup-dir option is ignored unless -b is given.

> The process is starting, deleting files, but the directory ~/old remains
> allways empty. This is not wanted.
>
> Creating a directory ~/old on machine 192.168.2.100 results either in an
> empty directory. Nor /dat/Musik_Originale/old neither /dat/old or
> even /home/a_user/old (on both computers) contained the wanted data.

The directory named with --backup-dir is on the target host and, if it
isn't a full path, is relative to the target directory.

As rsync doesn't perform tilde interpretation, ~/old would be (with -b)
taken as:

192.168.2.103:/dat/Music_Original/~/old

Which would probably be removed (due to --delete) before the backups
could be moved into it.

Try this (/home/a_user/old is on the remote machine):

rsync --delete -av --progress -b --backup-dir=/home/a_user/old \
/dat/Musik_Originale/ ro...@192.168.2.103:/dat/Musik_Originale/

Thomas 'PointedEars' Lahn

unread,
Mar 28, 2014, 5:10:59 PM3/28/14
to
Ralf S. Hellersen wrote:

> Hello rsync users !

This is a newsgroup for shell-scripting, but I am told that tools that can
be used in shells are on-topic here, too.

> I would like to perform on my machine (192.168.2.100) the following
> process in order to get rid of the files on computer 192.168.2.103, but
> to have them moved and collected for further analyses in directory ~/old
> on the (remote) machine 192.168.2.103.
>
> # rsync --delete -av --progress /dat/Musik_Originale/ ro...@192.168.2.103:/
> dat/Musik_Originale/ --backup-dir=~/old ;
>
> The process is starting, deleting files, but the directory ~/old remains
> allways empty. This is not wanted.
>
> Creating a directory ~/old on machine 192.168.2.100 results either in an
> empty directory. Nor /dat/Musik_Originale/old neither /dat/old or
> even /home/a_user/old (on both computers) contained the wanted data.
>
> My search in different sources was not successfull, but I know
> there must be a solution.

RTFM:

,----[rsync(1)]
|
| --backup-dir=DIR
| In combination with the --backup option, this tells rsync to
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| store all backups in the specified directory on the
| receiving side.
| This can be used for incremental backups. You can
| additionally specify a backup suffix using the --suffix
| option (otherwise the files backed up in the specified
| directory will keep their original filenames).
|
| Note that if you specify a relative path, the backup
| directory will be relative to the destination directory, so
| you probably want to specify either an absolute path or a
| path that starts with "../". If an rsync daemon is the
| receiver, the backup dir cannot go outside the module’s path
| hierarchy, so take extra care not to delete it or copy into
| it.
|
`----

> My questions are, did I use the correct syntax

I can see nothing wrong with the syntax, however I suggest that you use
options before positional arguments always. Not all tools observe POSIX
rules.

> and where is the mistake ?

As should be obvious to you now, you have forgotten to specify the
“--backup” option.

And there should be no whitespace before sentence-ending marks in English
(and other Germanic languages). BTW, there is de.comp.os.unix.shell, too.

> Where could I create this directory ~/old precisly ?

Per the man(ual) page, it would be created “on the receiving side”. As the
receiving side is your local filesystem, it should be created there.

--
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Ralf S. Hellersen

unread,
Mar 28, 2014, 7:00:17 PM3/28/14
to
Many thanks, Dave !

Now I did this:

rsync --delete -av --progress -b --backup-dir=Trash /dat/Musik_Originale/
Oldies/ ro...@192.168.2.103:/dat/Musik_Originale/Oldies

The files shall just be moved to a new directory and stay on the same
partition.

It first told me to delete the files, which is correct, but afterwards
it said "deleting /Trash" which is not wanted, since /dat/Musik_Originale/
Trash remained again empty.

What is the mistake now and how can I get it working correct ?

Dave Sines

unread,
Mar 29, 2014, 7:41:12 AM3/29/14
to
Ralf S. Hellersen <schne...@arcor.de> wrote:

> Now I did this:
>
> rsync --delete -av --progress -b --backup-dir=Trash /dat/Musik_Originale/
> Oldies/ ro...@192.168.2.103:/dat/Musik_Originale/Oldies
>
> The files shall just be moved to a new directory and stay on the same
> partition.
>
> It first told me to delete the files, which is correct, but afterwards
> it said "deleting /Trash" which is not wanted, since /dat/Musik_Originale/
> Trash remained again empty.

If the directory named with --backup-dir= is not an absolute path, it
is taken as relative to the target directory.

In:

--backup-dir=Trash ... ro...@192.168.2.103:/dat/Musik_Originale/Oldies

rsync uses this as the backup directory:

ro...@192.168.2.103:/dat/Musik_Originale/Oldies/Trash

Which is removed as there is no /dat/Music_Originale/Oldies/Trash on the
source host.

Add --exclude=Trash:

rsync --delete -av --progress -b --backup-dir=Trash --exclude=Trash \
/dat/Musik_Originale/Oldies/ \
ro...@192.168.2.103:/dat/Musik_Originale/Oldies

Or use a backup directory outside the target heirarchy. Given:

--backup-dir=../Oldies.Trash

rsync will move the files which would be deleted or modified to:

ro...@192.168.2.103:/dat/Musik_Originale/Oldies.Trash

Consider using date-stamped backups:

--backup-dir="../Trash/Oldies/$( date +'%Y%m%d%H%M%S' )"

Ralf S. Hellersen

unread,
Aug 6, 2014, 7:44:03 AM8/6/14
to
Thanks to all for your comments !

I got it running. I did not expect to be forced to tell -rsync- to
say again, that I would like to do backup. I expected to have done enough
to tell rsync that I need to make a backup directory.
0 new messages