0

I'm moving files from pCloud to Google Drive and when using Finder the copy process aborts sometimes due to invisible files and what not.

So i'm using cp -r command in Terminal (Google Drive's top level shared drives need to be created in the Drive Admin tool so that part is a manual process).

the pCloud driver keeps crashing mid-operation, so i have to restarted the driver and start from where i left off by reissuing the command.

wondering if there's a command in macOS terminal that will confirm that I have mirror copies in Google Drive of the pCloud repository, given all the failed attempts due to invisible files and driver crashes.

3
  • 3
    Might be easier to use rsync which is able to restart/continue if it aborts for whatever reason.
    – nohillside
    Dec 2 '21 at 8:09
  • thanks. copy is smart enough to pick up where it crashed last time, it starts working on the next uncopied folder straight away. I'll check out rsync for sure for future use, thanks. Dec 6 '21 at 8:48
  • Are you using a non-standard version of cp?
    – nohillside
    Dec 6 '21 at 9:01
14

The answer to this is rsync. Not just to do the copy as @nohillside suggests but it can be setup to do just a verification.

Normally I would say you need to get a newer version of rsync than macOS provides as the macOS one does not keep extended attributes but as cloud synchronizers don't either then that will not matter.

You can run rsync to do a dry-run, that is not to copy any files but just report the differences. The command is

rsync --dry-run -av pcloud-dir/ gdrive-dir/

A copy can be done by removing --dry-run This has another advantage over Finder in that if the copy is interrupted then you can just repeat the same command and it will not recopy the files already done.

3
  • 2
    rsync --dry-run -av pcloud-dir gdrive-dir will sync pcloud-dir into gdrive-dir, which is to say it'll create the directory gdrive-dir/pcloud-dir and copy files under that. If you want it to sync pcloud-dir with gdrive-dir (i.e. with sync the directories themselves, not create a subdirectory), you need to add a / to the end of the source path: rsync --dry-run -av pcloud-dir/ gdrive-dir Dec 2 '21 at 21:40
  • 1
    @GordonDavisson Thanks I always end up doing a dry-run to sort directories out
    – mmmmmm
    Dec 2 '21 at 21:46
  • 2
    These days I prefer -i to -v because it gives an indication of what is different (permissions, timestamp, content). So I would use: rsync -ain [dir1] [dir2] Dec 3 '21 at 8:11
4

Agree with @mmmmmm ; rsync is the better choice over cp

An alternative to rsync to determine

if there's a command in macOS terminal that will confirm that I have mirror copies in Google Drive of the pCloud repository

one can use the diff command. diff can provide a comparison of two directories and will return what exists only in one folder or another, or nothing at all if they are the same.

diff -r /path/to/dir1 /path/to/dir2

And, if @wide_eyed_pupil you are intent on sticking with cp, you can add some arguments to not copy files already in the destination and to preserve attributes and permissions.
For example:

cp -nRav

have a look at man cp to see what all the arguments do.

Also, of note from the man page..

COMPATIBILITY Historic versions of the cp utility had a -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links, or fifo's.

(use -R instead)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .