On 2025-10-21, Java Jive wrote:
On 2025-10-21 16:37, Dan Purgert wrote:
rsync cannot "backup" something it doesn't know about or isn't
changing... likewise your command shouldn't have deleted "extratest"
My mistake, in my post above I didn't transcribe the process directly because for other reasons I'd already logged out of the server. Below I
do so, but get the same result ...
[...]
Unfortunately, this doesn't happen with this rsync on these QNAP servers whether or not I specify an absolute path to elsewhere:
[user@server Test]# mkdir 1temp 2temp elsewhere
[user@server Test]# touch 1temp/test
[user@server Test]# touch 2temp/extratest
[user@server Test]# rsync -av --backup-dir=elsewhere --delete 1temp/ 2temp/
Could be a version thing, yeah. Here's what I'm working with:
dan@framework:~/rsync$ rsync --version
rsync version 3.2.7 protocol version 32
[...more stuff...]
For ref, did the exact commands you posted, just in case my previous
test somehow handled the backup-dir because I did rsync without delete
first.
dan@framework:~/rsync$ mkdir 1temp 2temp
dan@framework:~/rsync$ touch 1temp/test
dan@framework:~/rsync$ touch 2temp/extratest
(NB: edited command to deal with line-wrapping)
dan@framework:~/rsync$ rsync -av --backup-dir=elsewhere --delete \
1temp/ 2temp/
sending incremental file list
deleting extratest
../
test
sent 116 bytes received 51 bytes 334.00 bytes/sec
total size is 0 speedup is 0.00
dan@framework:~/rsync$ ls -al 1temp/*
-rw-r--r-- 1 dan dan 0 Oct 21 15:32 1temp/test
dan@framework:~/rsync$ ls -al 2temp/*
-rw-r--r-- 1 dan dan 0 Oct 21 15:32 2temp/test
2temp/elsewhere:
total 8
drwxr-xr-x 2 dan dan 4096 Oct 21 15:33 .
drwxr-xr-x 3 dan dan 4096 Oct 21 15:32 ..
-rw-r--r-- 1 dan dan 0 Oct 21 15:32 extratest
There might also be the issue that the testing is using zero-byte files,
that has caused me heartache in the past.
Realistically though, as I understand your actual situation, this series
of commands is closer to what happened, right?
(1) Created some new source directory (and files), then ran rsync dan@framework:~/rsync$ mkdir -p src/oops dest
dan@framework:~/rsync$ touch src/oops/somefile.txt
dan@framework:~/rsync$ rsync -av src/ dest
sending incremental file list
oops/
oops/somefile.txt
sent 157 bytes received 39 bytes 392.00 bytes/sec
total size is 0 speedup is 0.00
(2) Realized there was a mistake, corrected the source tree... dan@framework:~/rsync$ mkdir src/correct
dan@framework:~/rsync$ mv src/oops/somefile.txt src/correct/somefile.txt dan@framework:~/rsync$ rmdir src/oops
(3)need to re-sync with the destination, and cleanup the wrong files.
Dry-run to make sure stuff we expect to happen will happen...
(NB: edited the command to deal with line-wrapping)
dan@framework:~/rsync$ rsync -av --backup-dir=backupdir --delete \
--dry-run src/ dest
sending incremental file list
deleting oops/somefile.txt
deleting oops/
../
correct/
correct/somefile.txt
sent 130 bytes received 56 bytes 372.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
(4) dry-run looked good, so run without that switch.
(NB: Edited the command to deal with line-wrapping)
dan@framework:~/rsync$ rsync -av --backup-dir=backupdir --delete \
src/ dest
sending incremental file list
deleting oops/somefile.txt
deleting oops/
../
correct/
correct/somefile.txt
sent 170 bytes received 76 bytes 492.00 bytes/sec
total size is 0 speedup is 0.00
(5) checked the result
dan@framework:~/rsync$ ls -al src
total 12
drwxr-xr-x 3 dan dan 4096 Oct 21 15:42 .
drwxr-xr-x 4 dan dan 4096 Oct 21 15:42 ..
drwxr-xr-x 2 dan dan 4096 Oct 21 15:42 correct
dan@framework:~/rsync$ ls -al dest/
total 16
drwxr-xr-x 4 dan dan 4096 Oct 21 15:42 .
drwxr-xr-x 4 dan dan 4096 Oct 21 15:42 ..
drwxr-xr-x 3 dan dan 4096 Oct 21 15:43 backupdir
drwxr-xr-x 2 dan dan 4096 Oct 21 15:42 correct
--
|_|O|_|
|_|_|O| Github:
https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860
--- MBSE BBS v1.1.1 (Linux-x86_64)
* Origin: A noiseless patient Spider (2:250/1@fidonet)