Last active
December 24, 2019 10:48
-
-
Save steve-ross/9958469 to your computer and use it in GitHub Desktop.
Magento Tar Directory Script
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 "////////////////////////// MAGENTO TAR ////////////////////////////" | |
date | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
excludefilename="$DIR/exclude_files.txt" | |
day=$(date +%A) | |
path=$1 | |
while : | |
do | |
if [ -d "${path}" ] | |
then | |
break | |
elif [ -f "${path}" ] | |
then echo "${path} is a file, please supply a directory" | |
read path | |
else echo "${path} not a valid path, please try again" | |
echo "usage without prompts: ./tar_mage_directory.sh directory ctrl-c aborts" | |
read path | |
fi | |
done | |
newvar=${path%/} | |
`cat << EOF > $excludefilename | |
.DS_Store | |
./var/cache/* | |
*.log | |
./dev/* | |
./var/log/* | |
./stylenotes/* | |
./var/* | |
./includes/src/* | |
./media/catalog/product/cache/* | |
./media/tmp/* | |
./media/catalog/cache/* | |
EOF | |
` | |
file="$DIR/magento-backup-$day.tar.gz" | |
echo "Creating archive of $path" | |
CMD=`tar -X $excludefilename -zcvf $file -C $path .` | |
date | |
echo "///////////////////////// MAGENTO TAR END ////////////////////////////" | |
echo "to copy this file to another server that you have ssh access to use scp for example:" | |
echo "scp $file user@host:/host/destination/path" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment