(from http://www.samba.org/ftp/rsync/rsync.html)
In summary: to give destination files (both old and new) the source permissions, use --perms
.
To give new files the destination-default permissions (while leaving existing files unchanged), make sure that the --perms
option is off and use --chmod=ugo=rwX
(which ensures that all non-masked bits get enabled).
If you'd care to make this latter behavior easier to type, you could define a popt alias for it, such as putting this line in the file ~/.popt (the following defines the -Z option, and includes --no-g to use the default group of the destination dir):
rsync alias -Z --no-p --no-g --chmod=ugo=rwX
Meanwhile I have worked out any issues and have a solution which works for me since a few weeks. In case anybody is interested I am posting the details here. This article by Troy Johnson has helped along the way.
Prerequisites
- Truecrypt installed on Linux and available on the path
- a TC container prepared and available at
/home/deepc/var/backup.tc
- cygwin and rsync installed on Windows and available on the path
Linux
I made two shell scripts to mount and unmount the Truecrypt container on the Linux box. Those scripts are being called remotely via ssh from the Windows machine:
~/bin/backup-mount.sh:
#!/bin/bash
# usage: backup-mount.sh <password>
~deepc/bin/backup-umount.sh
echo "$1" | sudo truecrypt -t --slot=2 -k "" --volume-type=normal --protect-hidden=no /home/deepc/var/backup.tc /home/deepc/mnt
~/bin/backup-umount.sh:
#!/bin/sh
sudo truecrypt -d /home/deepc/var/backup.tc
Windows
remote-backup.cmd:
@echo off
setlocal
set HOME=c:\home
set LC_ALL=de_DE.utf-8
set LC_CTYPE=de_DE.utf-8
set LANG=de_DE.utf-8
rem --iconv=utf-16,iso-88591
ssh -p THESSHPORT -i ../.ssh/id_dsa deepc@theremotehost.com bin/backup-mount.sh THEPASSWORD
rsync -rltvzPm --modify-window=1 --exclude-from=../etc/backup/excludes.txt --chmod=ugo=rwX --delete --delete-excluded --files-from=../etc/backup/files-from.txt -e "ssh -p THESSHPORT -i ../.ssh/id_dsa" --log-file=../tmp/remote-backup.log /cygdrive deepc@theremotehost.com:/home/deepc/mnt
ssh -p THESSHPORT -i ../.ssh/id_dsa deepc@theremotehost.com bin/backup-umount.sh
Put this batch file into the task scheduler, e.g. with a daily schedule. Be sure to adjust username, remote host, ssh port, Truecrypt container password, and of course the backup paths. Sorry but I could not bring myself to clean this up more after having wasted too much time already...
With this script Rsync will read includes and excludes from two text files, e.g.:
files-from.txt:
/c/Home/
/c/Users/deepc
...
excludes.txt:
Firefox/Cache
Firefox/*.lock
Thunderbird/*.lock
Thunderbird/**/*Junk*
Thunderbird/**/filterlog.html
Thunderbird/**/*.msf
Home/tmp
...
Done?
This is answers the original question. There is only one minor issue: special characters in filenames on Windows are mangled on Linux, with ext2 being used in the TC container on Linux. I tried all combinations for the --iconv
parameter I could think of but to no avail. Seems I have to live with that - unless some brave soul has read until here, knows the answer, and enlightens me in a comment ;-) (NTFS in the container is not an option)
Best Answer
I think your basic problem here is that
rsync
is not a good tool for two-way synchronization. I would recommend some solution conceptually different, otherwise you will keep clobbering yourself.Unison
. It functions similar torsync
but is designed for two say synchronization.git
. This is particularly useful for things like config files and your personal scripts. Each machine you use them on will have a separate checkout, and the versioning takes care of making sure that you always have the latest changes by time including merging multiple different changes rather than just having the data clobbered from any one source.