Backup of multiple sites on Ubuntu

I have multiple sites in my /var/www/html/ folder like following:-

/var/www/html/site-1 
/var/www/html/site-2 
/var/www/html/site-3
/var/www/html/site-4

i want to zip each site on my server and to sync on s3 bucket.

Answer

One zip for each site:

for num in $(seq 1 4); do zip -r "/tmp/backup-site-${num}.zip" "/var/www/html/site-${num}" && aws s3 cp "/tmp/backup-site-${num}.zip" "s3://yourbucketname/"; done

One zip for all sites:

zip -r /tmp/site-backup.zip /var/www/html/site-[1-4] && aws s3 cp "/tmp/site-backup.zip" "s3://yourbucketname/"

Attribution
Source : Link , Question Author : Sukhjinder Singh , Answer Author : Alberto Pau

Leave a Comment