rsync: How to copy files to another file system just once unless updated?

rsync: How to copy files to another file system just once unless updated?

I need to transfer some files from my Ubuntu computer to my Google Drive, mounted as gdfuse using google-drive-ocamlfuse. My go-to way to do this would be to run

rsync -avhP /home/me/python /media/me/googledrive/python

My dream was that all files would be copied once, and after that, every time I ran that command, it would only copy files changed since the last sync. However, it always copies all the files.

It seems from this that this is simply not possible, because new files on a new file system will always be assigned a timestamp for when the new file was created on the new file system. I basically need someone to tell me that what I want is not possible. Because that's how I understand it. So is my understanding correct?

EDIT: As per request by roaima, I've made a small text file, and synced it to my google drive. Below is the output of stat of the two files, unmount, remount, stat again, and sync again, where the entire file is transferred again:

$ stat test.txt /media/me/googledrive/test.txt
  File: test.txt
  Size: 29          Blocks: 8          IO Block: 4096   regular file
Device: 10305h/66309d   Inode: 396449      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   me)   Gid: ( 1000/   me)
Access: 2020-11-18 12:55:36.013411183 +0100
Modify: 2020-11-18 12:55:33.329397154 +0100
Change: 2020-11-18 12:55:33.329397154 +0100
 Birth: -
  File: /media/me/googledrive/test.txt
  Size: 29          Blocks: 1          IO Block: 512    regular file
Device: 86h/134d    Inode: 4360        Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   me)   Gid: ( 1000/   me)
Access: 1970-01-01 01:00:00.000000000 +0100
Modify: 2020-11-18 12:58:27.000000000 +0100
Change: 2020-11-18 12:58:27.000000000 +0100
 Birth: -
$ sudo umount /media/me/googledrive   
[sudo] password for me: 
$ google-drive-ocamlfuse /media/me/googledrive/
$ stat test.txt /media/me/googledrive/test.txt
  File: test.txt
  Size: 29          Blocks: 8          IO Block: 4096   regular file
Device: 10305h/66309d   Inode: 396449      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   me)   Gid: ( 1000/   me)
Access: 2020-11-18 12:55:36.013411183 +0100
Modify: 2020-11-18 12:55:33.329397154 +0100
Change: 2020-11-18 12:55:33.329397154 +0100
 Birth: -
  File: /media/me/googledrive/test.txt
  Size: 29          Blocks: 1          IO Block: 512    regular file
Device: 85h/133d    Inode: 102         Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   me)   Gid: ( 1000/   me)
Access: 1970-01-01 01:00:00.000000000 +0100
Modify: 2020-11-18 12:58:27.000000000 +0100
Change: 2020-11-18 12:58:27.000000000 +0100
 Birth: -
$ rsync -avhP --stats test.txt /media/me/googledrive/
sending incremental file list
test.txt
             29 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)

Number of files: 1 (reg: 1)
Number of created files: 0
Number of deleted files: 0
Number of regular files transferred: 1
Total file size: 29 bytes
Total transferred file size: 29 bytes
Literal data: 29 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 137
Total bytes received: 35

sent 137 bytes  received 35 bytes  20.24 bytes/sec
total size is 29  speedup is 0.17

相关内容