# redash.0.11.0.b2016 to redash.0.12.0.b2449
$ upgrade.sh 0.12.0.b2449
Last active
November 28, 2016 08:13
-
-
Save tkuchiki/eb14ed34e4744a7f48a0a7ad820fdd41 to your computer and use it in GitHub Desktop.
Upgrade redash(port of https://gist.github.com/arikfr/440d1403b4aeb76ebaf8)
This file contains hidden or 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 | |
new_version="${1}" | |
if [ "${new_version}" = "" ]; then | |
echo "\$1(= version) is required." | |
exit 1 | |
fi | |
new_version_path="/opt/redash/redash.${new_version}" | |
new_version_archive="redash.${new_version}.tar.gz" | |
base_dir=/opt/redash | |
current_version_path="$(readlink ${base_dir}/current)" | |
current_version="$(basename ${current_version_path})" | |
cd ${base_dir} | |
sudo wget --header="Accept: application/octet-stream" https://github.com/getredash/redash/releases/download/v${new_version}/${new_version_archive} | |
sudo mkdir -p ${new_version_path} | |
sudo tar -C ${new_version_path} -xvf ${new_version_archive} | |
sudo rm -f ${new_version_archive} | |
sudo chown redash -R ${new_version_path} | |
sudo ln -nfs ${base_dir}/.env ${new_version_path}/.env | |
if !(cmp ${current_version_path}/requirements.txt ${new_version_path}/requirements.txt); then | |
sudo pip install -r ${new_version_path}/requirements.txt | |
fi | |
# backup | |
sudo -u postgres pg_dump redash > ${current_version}.$(date +"%Y%m%dT%M%H%S").sql | |
cd ${new_version_path} | |
do_migration() { | |
sudo -u redash PYTHONPATH=. bin/run python ${1} | |
} | |
for f in $(find ${new_version_path}/migrations/ -type f | sort); do | |
current_f="${current_version_path}/migrations/$(basename ${f})" | |
if [ ! -f ${current_f} ]; then | |
do_migration ${f} | |
continue | |
fi | |
cmp -s ${f} ${current_f} || do_migration ${f} | |
done | |
sudo ln -nfs ${new_version_path} ${base_dir}/current | |
sudo service redash_supervisord restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment