Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.os.linux    |    Getting to be as bloated as Windows!    |    107,822 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 107,589 of 107,822    |
|    Java Jive to Dan Purgert    |
|    Re: rsync Question    |
|    21 Oct 25 17:44:02    |
      XPost: uk.comp.os.linux       From: java@evij.com.invalid              On 2025-10-21 16:37, Dan Purgert wrote:       > On 2025-10-21, Java Jive wrote:       >> On 2025-10-21 14:49, Dan Purgert wrote:       >>> On 2025-10-21, Java Jive wrote:       >>>> Having made a slight cock-up, I want to use rsync to move all the files       >>>> that exist on one server but not the other into a separate heirarchy.       >>>>       >>>> More fully:       >>>>       >>>> I have two identical servers, the second of which rsyncs itself from the       >>>> other overnight. This morning, due to an oversight, I put a load of       >>>> files into a directory structure that were intended to go into a       >>>> subfolder of it. What I want to do is rsync from the second server to       >>>> the first and move files that only exist on the first into a directory       >>>> tree elsewhere on the server, so that then I can move that extraneous       >>>> tree back into the originally intended subfolder. Something like this:       >>>       >>> rsync doesn't 'move'.       >>>       >>> *IF* you've already moved the relevant files from /src/wrongdir to       >>> /src/correctdir ; then you can rsync with "--delete" to delete those       >>> files on /dest/ that are no longer in /src/ (i.e. 'got moved from       >>> /src/wrong/ to /src/correct/').       >>>       >>> I would definitely do the --dry-run, and read it *very* closely, to make       >>> sure the rsync isn't removing more than I expect.       >>       >> Yes, after posting I did a test along the following lines which proved       >> the files would be deleted, not moved ...       >>       >> mkdir 1temp 2temp elsewhere       >> touch 1temp/test       >> touch 2temp/extratest       >>       >> rsync -a --backup-dir=elsewhere 1temp/ 2temp/       >>       >> ls -al 1temp       >> .       >> ..       >> test       >> ls -al 2temp       >> .       >> ..       >> test       >> ls -al elsewhere       >> .       >> ..       >>       >> :-(       >       > rsync cannot "backup" something it doesn't know about or isn't       > changing... likewise your command shouldn't have deleted "extratest"       >       > dan@framework:~/rsync$ mkdir 1temp 2temp elsewhere       > dan@framework:~/rsync$ touch 1temp/test       > dan@framework:~/rsync$ touch 2temp/extratest       > dan@framework:~/rsync$ rsync -av --backup-dir=elsewhere 1temp/ 2temp/       > sending incremental file list       > ./       > test       >       > sent 116 bytes received 38 bytes 308.00 bytes/sec       > total size is 0 speedup is 0.00       >       > dan@framework:~/rsync$ ls -la 1temp       > total 8       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:31 .       > drwxr-xr-x 5 dan dan 4096 Oct 21 11:31 ..       > -rw-r--r-- 1 dan dan 0 Oct 21 11:31 test       > dan@framework:~/rsync$ ls -la 2temp       > total 8       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:31 .       > drwxr-xr-x 5 dan dan 4096 Oct 21 11:31 ..       > -rw-r--r-- 1 dan dan 0 Oct 21 11:31 extratest       > -rw-r--r-- 1 dan dan 0 Oct 21 11:31 test       > dan@framework:~/rsync$ ls -la elsewhere       > total 8       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:31 .       > drwxr-xr-x 5 dan dan 4096 Oct 21 11:31 ..              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 ...              > Now, if we add in '--delete' ...       >       > dan@framework:~/rsync$ rsync -av --delete --backup-dir=elsewhere 1temp/       > 2temp/ sending incremental file list       > deleting extratest       >       > sent 70 bytes received 25 bytes 190.00 bytes/sec       > total size is 0 speedup is 0.00       > dan@framework:~/rsync$ ls -la 1temp       > total 8       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:31 .       > drwxr-xr-x 5 dan dan 4096 Oct 21 11:31 ..       > -rw-r--r-- 1 dan dan 0 Oct 21 11:31 test       > dan@framework:~/rsync$ ls -la 2temp       > total 12       > drwxr-xr-x 3 dan dan 4096 Oct 21 11:31 .       > drwxr-xr-x 5 dan dan 4096 Oct 21 11:31 ..       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:33 elsewhere       > -rw-r--r-- 1 dan dan 0 Oct 21 11:31 test       > dan@framework:~/rsync$ ls -la elsewhere       > total 8       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:31 .       > drwxr-xr-x 5 dan dan 4096 Oct 21 11:31 ..       > dan@framework:~/rsync$ ls -la 2temp/elsewhere/       > total 8       > drwxr-xr-x 2 dan dan 4096 Oct 21 11:33 .       > drwxr-xr-x 3 dan dan 4096 Oct 21 11:31 ..       > -rw-r--r-- 1 dan dan 0 Oct 21 11:31 extratest       >       > NOTE -- the deleted file went into "2temp/elsewhere", because of the       > behavior of --backup-dir:       >       > Note that if you specify a relative path, the backup directory       > will be relative to the destination directory,              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/       sending incremental file list       2./       deleting extratest       test              sent 81 bytes received 34 bytes 230.00 bytes/sec       total size is 0 speedup is 0.00       [user@server Test]# ls -al 1temp       total 8       drwxr-xr-x 2 user user 4096 2025-10-21 17:28 ./       drwxrwx--- 8 user user 4096 2025-10-21 17:27 ../       -rw-r--r-- 1 user user 0 2025-10-21 17:28 test       [user@server Test]# ls -al 2temp       total 8       drwxr-xr-x 2 user user 4096 2025-10-21 17:28 ./       drwxrwx--- 8 user user 4096 2025-10-21 17:27 ../       -rw-r--r-- 1 user user 0 2025-10-21 17:28 test       [user@server Test]# ls -al elsewhere       total 8       drwxr-xr-x 2 user user 4096 2025-10-21 17:27 ./       drwxrwx--- 8 user user 4096 2025-10-21 17:27 ../       [user@server Test]# mkdir 2temp/elsewhere       [user@server Test]# touch 2temp/extratest       [user@server Test]# rsync -av --backup-dir=elsewhere --delete 1temp/ 2temp/       sending incremental file list       ./       deleting elsewhere/       deleting extratest              sent 42 bytes received 15 bytes 114.00 bytes/sec       total size is 0 speedup is 0.00       [user@server Test]# ls -al elsewhere       total 8       drwxr-xr-x 2 user user 4096 2025-10-21 17:27 ./       drwxrwx--- 8 user user 4096 2025-10-21 17:27 ../       [user@server Test]# touch 2temp/extratest       [user@server Test]# rsync -av --backup-dir=/LocalPath/elsewhere --delete       1temp/ 2temp/       sending incremental file list       ./       deleting extratest              sent 46 bytes received 15 bytes 122.00 bytes/sec       total size is 0 speedup is 0.00       [user@server Test]# ls -al /LocalPath/elsewhere       total 8       drwxr-xr-x 2 user user 4096 2025-10-21 17:27 ./       drwxrwx--- 8 user user 4096 2025-10-21 17:27 ../              --              Fake news kills!              I may be contacted via the contact address given on my website:       www.macfh.co.uk              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca