70 likes | 82 Views
Sometimes you may need to backup website to Amazon S3. Here are the steps to do it.<br><br>Visit https://fedingo.com/how-to-backup-website-to-amazon-s3/
E N D
Install AWSCLI AWSCLI is available in almost every default Linux repository. So you can easily install it with the following commands, depending on your Linux distribution. $ sudo dnf install awscli ## Fedora, Redhat and CentOS $ sudo apt install awscli ## Ubuntu, Debian and Linux Mint Run the following command to verify installation. $ aws --version
Create Shell Script (1 of 2) Create following shell script #/usr/bin/env bash S3_BUCKET_NAME="" DIR_TO_BACKUP="/var/www/html" BACKUP_FILENAME='website' TODAY=`date +%Y%m%d` YY=`date +%Y` MM=`date +%m`
Create Shell Script (2 of 2) AWSCMD="/usr/local/bin/aws" TARCMD="/usr/bin/tar" ${TARCMD} czf /tmp/${BACKUP_FILENAME}-${TODAY}.tar.gz ${AWSCMD} cp /tmp/${BACKUP_FILENAME}-${TODAY}.tar.gz s3://${S3_BUCKET_NAME}/${YY}/${MM}/ if [ $? -eq 0 ]; then echo "Backup successfully uploaded to s3 bucket" else echo "Error in s3 backup" fi
Make Shell Script Executable Run the following command to make shell script executable. $ chmod +x /scripts/website_backup.sh Now you can run the script with the following command. $ bash /scripts/website_backup.sh
Create Cronjob Open Crontab with the following command. $ crontab -e Add the following entry to your crontab to run website_backup.sh script every day at 10 a.m. 0 10 * * * bash /scripts/website_backup.sh
Thank You Visit for details https://fedingo.com/how-to-backup-website-to-amazon-s3/