Skip to content

Instantly share code, notes, and snippets.

@sunny4381
Created August 9, 2023 06:41
Show Gist options
  • Save sunny4381/562b45e56b136631c2d5f11f89022d9d to your computer and use it in GitHub Desktop.
Save sunny4381/562b45e56b136631c2d5f11f89022d9d to your computer and use it in GitHub Desktop.
#!/bin/bash
base_dir=$(cd "$(dirname $0)" && pwd)
proj_dir=$(pwd)
prefix=${prefix:-"ss"}
version=${version:-"20190529-1356"}
echo "pwd: $proj_dir"
cd $proj_dir
rm -rf private public
tar xf $proj_dir/,memo/$prefix-files-$version.tar.bz2
rm -rf public/assets
git checkout -- public/assets
if [ ! -f private/.keep ]; then
git checkout -- private/.keep
fi
cd $proj_dir
bin/rake db:drop
mkdir -p tmp/$$
cd tmp/$$
tar xf $proj_dir/,memo/$prefix-db-$version.tar.bz2
rm -rf ss_$prefix/{history_logs,history_backups,history_trashes,job_logs,sys_mail_logs,sessions}.*
mongorestore --db=ss_$prefix ss_$prefix
cd $proj_dir
if [ -f $base_dir/reset_sensitives.rb ]; then
echo $base_dir/reset_sensitives.rb
bin/rails runner $base_dir/reset_sensitives.rb -e development
fi
cd $proj_dir
if [ -x $proj_dir/,memo/after_reset.sh ]; then
echo $proj_dir/,memo/after_reset.sh
$proj_dir/,memo/after_reset.sh
fi
rm -rf coverage log/* tmp/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment