rclone/fs/logger/testdata/script/TestBeforeVsAfter.txtar
nielash 3a50f35df9 sync: report list of synced paths to file -- see #7282
Allows rclone sync to accept the same output file flags as rclone check,
for the purpose of writing results to a file.
A new --dest-after option is also supported, which writes a list file using
the same ListFormat flags as lsf (including customizable options for hash,
modtime, etc.) Conceptually it is similar to rsync's --itemize-changes, but
not identical -- it should output an accurate list of what will be on the
destination after the sync.

Note that it has a few limitations, and certain scenarios
are not currently supported:

--max-duration / CutoffModeHard
--compare-dest / --copy-dest (because equal() is called multiple times for the
    same file)
server-side moves of an entire dir at once (because we never get the individual
file objects in the dir)
High-level retries, because there would be dupes
Possibly some error scenarios that didn't come up on the tests

Note also that each file is logged during the sync, as opposed to after, so it
is most useful as a predictor of what SHOULD happen to each file
(which may or may not match what actually DID.)

Only rclone sync is currently supported -- support for copy and move may be
added in the future.
2024-01-20 14:50:08 -05:00

48 lines
2.1 KiB
Plaintext

# tests whether an md5sum file generated post-sync matches our pre-sync prediction
# Filling src and dst with two different versions of rclone source!:
exec rclone copyurl https://github.com/rclone/rclone/archive/refs/tags/v1.49.1.zip $SRC/src.zip
exec rclone copyurl https://github.com/rclone/rclone/archive/refs/tags/v1.54.1.zip $DST/dst.zip
exec unzip $SRC/src.zip -d $SRC
exec unzip $DST/dst.zip -d $DST
# generating sumfiles:
exec rclone md5sum $SRC --output-file $WORK/src-before.txt
exec rclone md5sum $DST --output-file $WORK/dst-before.txt
# running sync with output files:
exec rclone sync $SRC $DST --match $WORK/SYNCmatch.txt --combined $WORK/SYNCcombined.txt --missing-on-src $WORK/SYNCmissingonsrc.txt --missing-on-dst $WORK/SYNCmissingondst.txt --error $WORK/SYNCerr.txt --differ $WORK/SYNCdiffer.txt --dest-after $WORK/SYNCdestafter.txt --format 'hp' --separator ' '
# generating sumfiles:
exec rclone md5sum $SRC --output-file $WORK/src-after.txt
exec rclone md5sum $DST --output-file $WORK/dst-after.txt
# sorting them by line and diffing:
exec sort $WORK/src-before.txt -o $WORK/src-before.txt
exec sort $WORK/dst-before.txt -o $WORK/dst-before.txt
exec sort $WORK/src-after.txt -o $WORK/src-after.txt
exec sort $WORK/dst-after.txt -o $WORK/dst-after.txt
exec sort $WORK/SYNCmatch.txt -o $WORK/SYNCmatch.txt
exec sort $WORK/SYNCcombined.txt -o $WORK/SYNCcombined.txt
exec sort $WORK/SYNCmissingonsrc.txt -o $WORK/SYNCmissingonsrc.txt
exec sort $WORK/SYNCmissingondst.txt -o $WORK/SYNCmissingondst.txt
exec sort $WORK/SYNCerr.txt -o $WORK/SYNCerr.txt
exec sort $WORK/SYNCdiffer.txt -o $WORK/SYNCdiffer.txt
exec sort $WORK/SYNCdestafter.txt -o $WORK/SYNCdestafter.txt
# diff src before vs src after:
cmp $WORK/src-before.txt $WORK/src-after.txt
# diff dst before vs dst after:
! cmp $WORK/dst-before.txt $WORK/dst-after.txt
# diff src before vs dst after:
cmp $WORK/src-before.txt $WORK/dst-after.txt
# diff dst before vs src after:
! cmp $WORK/dst-before.txt $WORK/src-after.txt
# diff md5sum dst after vs sync dest-after:
cmp $WORK/dst-after.txt $WORK/SYNCdestafter.txt