Do file sync between google cloud instances
By default, gcp instance can only log in with ssh key based, and if the ssh key is not generated for the root account (or the account that needs to execute rsync), it means that the rsync command cannot be used.
In gcloud sdk, only copy and scp (actually the same) are provided for file transfer between instances, unless bucket storage is used as a relay station.
However, using gcloud compute scp or gcloud compute copy cannot process only the updated files, and there are problems such as wasting bandwidth and time. At this time, make good use of the find command... For example, something like this...
find /var/opt/sharingdata/ -type f -mmin -1 -exec gcloud compute scp --recurse --compress --internal-ip {} --zone asia-east1-c [instance-name]:/var/ opt/sharingdata/
Then hang up crontab and you're done.
Original link: Phanix's Blog
Like my work? Don't forget to support and clap, let me know that you are with me on the road of creation. Keep this enthusiasm together!