Skip to main content
deleted 282 characters in body
Source Link
mgutt
  • 557
  • 3
  • 21

--remove-source-files is perfectly fine if source and destination are on different volumes, but if they are on the same, you can use the following method to really move files.

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst. But note: It's still slower than mv as rsync executes a move on every file and not only on the root dir as mv would.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did not "delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src

--remove-source-files is perfectly fine if source and destination are on different volumes, but if they are on the same, you can use the following method to really move files.

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did not "delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src

--remove-source-files is perfectly fine if source and destination are on different volumes, but if they are on the same, you can use the following method to really move files.

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst. But note: It's still slower than mv as rsync executes a move on every file and not only on the root dir as mv would.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"
added 91 characters in body
Source Link
mgutt
  • 557
  • 3
  • 21

I found a way--remove-source-files is perfectly fine if source and destination are on different volumes, but if they are on the same, you can use the following method to move with rsync:really move files.

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and notnot copies files and as we compared /src against an empty dir it "deletes" everything to /dst.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did NOTnot "delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src

I found a way to move with rsync:

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did NOT "delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src

--remove-source-files is perfectly fine if source and destination are on different volumes, but if they are on the same, you can use the following method to really move files.

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did not "delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src
added 91 characters in body
Source Link
mgutt
  • 557
  • 3
  • 21

I found a way to move with rsync:

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did NOT delete"delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src

I found a way to move with rsync:

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files.

If you want to delete /src, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did NOT delete src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src

I found a way to move with rsync:

Before:

find /test
/test
/test/empty_dir
/test/src
/test/src/50GB.bin

Execute rsync:

# SECONDS=0
# rsync --delete --recursive --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
# echo "rsync needed $SECONDS seconds"
rsync needed 0 seconds

After:

find /test
/test
/test/dst
/test/dst/50GB.bin
/test/empty_dir
/test/src

This works because the --backup-dir feature moves and not copies files and as we compared /src against an empty dir it "deletes" everything to /dst.

If you want to delete the (now empty) /src dir, use another rsync hack:

rsync --recursive --delete --include="/src**" --exclude="*" /test/empty_dir/ "/test"

Usually I would expect, that it works with one command as follows, but it seems rsync has a bug, because it did NOT "delete" src/50GB.bin although it claims it did:

# rsync --itemize-changes --delete --recursive --include="/src**" --exclude="*" --backup --backup-dir=/test/dst /test/empty_dir/ /test/src
*deleting   src/50GB.bin
cannot delete non-empty directory: src
Source Link
mgutt
  • 557
  • 3
  • 21
Loading