-
Notifications
You must be signed in to change notification settings - Fork 37
Managing overview on amazon
-
overview-manage ssh production database
to log in to thedatabase
instance sudo -u postgres psql overview
This works even while the database is being modified. The backed-up database will have the exact same state as the database had when the backup started.
If you're backing up a database from a remote Postgres server:
- Find the host, username, database and password of the database to back up.
-
pg_dump -v --no-owner -Fc -f backup.psql --host HOST --user USERNAME DATABASE
and enter the password.
But if you're logged into the database
instance, it's easier (as long as you're in a directory with the right permissions):
sudo -u postgres pg_dump -v --no-owner -Fc -f backup.psql
(The --no-owner
is necessary when backing up from Heroku, because the Heroku username, which is gibberish, won't exist on our Amazon AWS server and so the restore will fail.)
-
Run
DROP SCHEMA public CASCADE; CREATE SCHEMA public; GRANT ALL PRIVILEGES ON SCHEMA public TO overview;
in a database shell. -
Run
sudo -u postgres pg_restore -v -c -d DATABASE --no-owner FILENAME
. This will work, though the owner will bepostgres
instead ofoverview
. -
Run
SELECT 'ALTER TABLE "' || tablename || '" OWNER TO overview;' FROM pg_tables WHERE schemaname = 'public';
in a database shell -
Copy/paste all resulting commands back into the same database shell.
-
In a database shell, run:
SELECT 'ALTER TYPE "' || typname || '" OWNER TO overview;' FROM (SELECT typname FROM pg_type WHERE oid IN (SELECT DISTINCT enumtypid FROM pg_enum)) x;
-
Copy/paste all resulting commands back into the same database shell.
-
overview-manage restart production
- Check out
aws-overview-config
- Edit the appropriate file--for instance,
templates/web/root/etc/init/overview-web-server.conf
will map to/etc/init/overview-web-server.conf
on theweb
instance. Look atconfig/config-sample.yml
andconfig/secrets-sample.yml
to see which variables are available to you; there are alsodatabase_ip
anddatabase_url
. - Commit and push the changes
-
overview-manage deploy-config ENV.INSTANCE
, e.g.,production.web
You may overwrite any system file, but you can never delete configuration files through this system. (You'll have to log in to each system manually.)
It may be more practical to:
- SSH to an instance (e.g.,
overview-manage ssh production web
) - Edit the config file and then make it take effect--for instance,
sudo restart overview-web-server
- Follow the above steps
This will save you from committing embarrassing typos.
See https://github.com/overview/aws-overview-tools/tree/master/manage
overview-manage ssh production web
ls /opt/overview/frontend
That gives the SHA1 commit that's deployed on web.
- Push a new version to Git
-
overview-manage ssh
to connect to themanage
instance, thencd /opt/overview/aws-overview-tools && git pull --rebase
. - Log out
It wouldn't be the end of the world if you modified the repository directly on the manage
instance and then pushed. But there wouldn't be an author in the commit logs.
Edit /home/ubuntu/.ssh/authorized_keys
.
After revoking somebody's access, remember that they may still own the private keys on the manage
instance. Those give access to Overview's GitHub projects (until they're open-source and come from a read-only https://
URL) and, if the firewall isn't on, the production
and staging
instances. So rotate those keys. by editing /home/ubuntu/.ssh/authorized_keys
on all instances, making them all use a new private key from the manage
instance. Delete and create a new manage
key on the EC2 Management Console, too, so future instances will use the new one.
(Written for https://www.pivotaltracker.com/n/projects/928628/stories/69190832)
overview-manage
stores files in a few places.
Let's iterate over them:
This stores Ivy and Node caches, so that the build system doesn't need to download the same files over and over again from remote repositories every time you deploy.
To wipe it, just attach the volume on the manage
instance, mkfs.ext4
it, and detach it.
This stores git checkouts and compiled code, so that repeated deploys don't need repeated builds.
We use instance storage. (In case of data loss, it would be faster to rebuild Overview than to revive the data.) So unmount /dev/xvdb
, mkfs.ext4
it, and mount it.
overview-manage
deploys to other servers. You may want to delete some files from there, too.
But that's a dangerous thing. If the servers are running, they're using the code in there. So shut down the servers first.
Also: config files get deployed throughout the other instances. If you're trying for a truly clean setup, it might be quicker to just spin up a new instance.