Created
January 20, 2018 04:44
-
-
Save zw963/4d3fb3ea6181afcd51ea5db56d372d06 to your computer and use it in GitHub Desktop.
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
bak_dir=~/Downloads | |
name=ik_kefu | |
full_name=$bak_dir/${name} | |
keep_count=3 | |
date=$(date '+%Y-%m-%dT%H%M') | |
[ -e $full_name.zip ] && mv $full_name.zip "$full_name$date.zip" | |
bak_files=$(find $bak_dir/ -maxdepth 1 -name "${name}????-??-??T????.zip" |sort -V) | |
if [ "$bak_files" ]; then | |
bak_files_count=$(echo "$bak_files" |wc -l) | |
let x=1 && | |
for i in $bak_files; do | |
if ((x>(($bak_files_count - $keep_count)))) ; then | |
break | |
fi | |
rm -f "$i" | |
let x++ | |
done | |
fi | |
RAILS_ENV=production bundle exec rake assets:precompile && \ | |
zip -r $full_name.zip . \ | |
-x ".git/*" -x "spec/*" -x "test/*" -x "log/*" -x "tmp/*" \ | |
-x "public/api_doc/*" -x "wiki/*" -x ".idea/*" -x "*/.DS_Store" \ | |
-x ".DS_Store" -x ".bundle/*" -x "bin/qrsync" -x "slate/*" \ | |
-x ".byebug_history" -x ".gitignore" -x ".nvmrc" -x ".rspec" \ | |
-x "*.*~" -x ".ruby-gemset" -x ".ruby-version" -x ".versions.conf" \ | |
-x ".rvmrc" -x "TAGS" && git clean -f -d . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment