Skip to content

Instantly share code, notes, and snippets.

@steve-ross
Last active December 24, 2019 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steve-ross/9958469 to your computer and use it in GitHub Desktop.
Save steve-ross/9958469 to your computer and use it in GitHub Desktop.
Magento Tar Directory Script
#!/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