debshots/bin/get-data-from-old-live-server.sh
Christoph Haas bedd2c48d1 Fixed data migration script
Development database is "localhost" again.
rsync is sped up by just checking the size of the files
Automatic db:migrate is called at the end.
2015-06-26 21:18:17 +02:00

41 lines
1.3 KiB
Bash
Executable file

#!/bin/sh -ex
#IMAGE_DEST=../public
IMAGE_DEST=public
#IMAGE_DEST=/local/screenshots
DB_HOST=localhost
#DB_HOST=torf
echo Getting screenshot files
rsync -v --size-only root@screenshots.debian.net:/home/debshots/debshots-screenshots.tar /tmp
echo Getting PostgreSQL dump
rsync -v --size-only root@screenshots.debian.net:/home/debshots/debshots.sql /tmp
echo Dropping existing database
set +e
psql -h $DB_HOST postgres debshots -c 'drop database debshots'
psql -h $DB_HOST postgres debshots -c 'drop database debshots_dev'
psql -h $DB_HOST postgres debshots -c 'drop database debshots_test'
set -e
echo Creating new database
psql -h $DB_HOST postgres debshots -c 'create database debshots owner debshots'
psql -h $DB_HOST postgres debshots -c 'create database debshots_dev owner debshots'
psql -h $DB_HOST postgres debshots -c 'create database debshots_test owner debshots'
echo Restoring PostgreSQL dump
psql -h $DB_HOST debshots debshots < /tmp/debshots.sql
psql -h $DB_HOST debshots_dev debshots < /tmp/debshots.sql
psql -h $DB_HOST debshots_test debshots < /tmp/debshots.sql
echo Unpacking screenshots tarball
#cd ../public
#cd $IMAGE_DEST
tar -C $IMAGE_DEST -xf /tmp/debshots-screenshots.tar
#mv public/live/screenshots/approved public/screenshots
#rm -r public/live
ln -fs public/live/screenshots/approved public/screenshots
rake db:migrate