Last active
August 29, 2015 14:12
-
-
Save StudioLE/6566bb47f24bbb2516a2 to your computer and use it in GitHub Desktop.
Backup directories locally and to S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "LE Backup Wizard v2" | |
echo "Which directory would you like to backup?[\"n\" to abort]" | |
ls /srv/ | |
read name | |
if [ $name = n ] | |
then | |
echo "Aborted" | |
exit | |
fi | |
file=$name"-"$(date +"%F-%H-%M") | |
origin="/srv/"$name | |
dir="/srv/lib/backups/dir/"$file | |
echo "Copying directory.." | |
cp -rp $origin $dir | |
echo "Directory copied" | |
echo "Would you like to tar the directory? [y/n]" | |
read execute | |
if [ $execute = n ] | |
then | |
echo "Aborted" | |
exit | |
fi | |
echo "Archiving directory.." | |
tar="/srv/lib/backups/tar/"$file".tar.gz" | |
tar -zcf $tar $dir | |
echo "Archived "$file" to "$tar | |
echo "Would you like to copy the tar to S3? [y/n]" | |
read s3 | |
if [ $s3 = n ] | |
then | |
echo "Aborted" | |
exit | |
fi | |
echo "Uploading to S3.." | |
aws s3 cp $tar s3://le-uno/tar/ | |
echo "Uploaded "$file" to S3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment