0

I want to Sync my server data to Google Cloud Storage to copy automatically using shell script. I don't know how to make script. Every time i need to use: gsutil -m rsync -d -r [Source] gs://[Bucket-name] If anyone knows the answer please help me!

1 Answer 1

0

To automate the sync process use cron job:

  1. Create a script to run with cron $ nano backup.sh
  2. Paste your gsutil command in the script $ gsutil -m rsync -d -r [Source_PATH] gs://bucket-name
  3. Make the script executable $ chmod +x backup.sh
  4. Based on your use case, put the shell script (backup.sh) in one of the below folders: a) /etc/cron.daily b) /etc/cron.hourly c) /etc/cron.monthly d) /etc/cron.weekly
  5. If you want to run this script for a specific time then go to the terminal and type: $ crontab -e
  6. Then simply call out the script with cron as often as you want, for example, in midnight: 00 00 * * * /path/to/your/backup.sh

In case you are using Windows on your local server, The commands will be the same as above but make sure to use Windows path instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.