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.
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.
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/"
#!/bin/bash
DATE=$(date +%d-%m-%Y)
BACKUP_DIR="/root/backup/web-backup"
# To create a new directory into backup directory location.
mkdir -p $BACKUP_DIR/$DATE
# take each website backup in separate name, use below format.
tar -zcvpf $BACKUP_DIR/website-1-$DATE.tar.gz /var/www/html/website-1
tar -zcvpf $BACKUP_DIR/website-2-$DATE.tar.gz /var/www/html/website-2
tar -zcvpf $BACKUP_DIR/website-3-$DATE.tar.gz /var/www/html/website-3
# Delete files older than 10 days
find $BACKUP_DIR/* -mtime +10 -exec rm {} \;
aws s3 sync $BACKUP_DIR code s3://code-backup-bucket --region us-west-1