pantheon-systems/terminus — pull request #11 by mikemilano (2013-08-27 15:16:56+00:00)
Title: psite-download-backup with support for site-name, latest, and user promp...

This provides a command to load an environment database from an existing backup. This is actually faster than sql-sync because the backup is already made and compressed. It downloads the compressed database file from s3, decompresses it, and writes over the targeted environment's db.

It builds on the psite-dl-backup pull request by adding psite-load-backup. It works very similar.

It takes 3 arguments:

- Sitename or site uuid
- Environment
- Bucket, or "latest"

It also supports prompted arguments if none are supplied.

Examples:

```
$ drush psite-load-backup ab123ab-klj234oiu-g21lidngilpskdfh dev 1234504000_automated
```
```
$ drush -y psite-dl-backup mysitename dev latest
```

Targetting an alias works, but obviously in the case of a remote system, Terminus needs to be installed there as well.
```
$ drush -y @some.alias psite-dl-backup mysitename dev latest
```
```
$ drush psite-load-backup
Select a site.
[0] : Cancel
[1] : mysite enterprise site-uuid
1
Select an environment.
[0] : Cancel
[1] : dev
[2] : test
[3] : live
1
Select a backup.
[0] : Cancel
[1] : mysite_dev_2013-08-27T08-00-00_database.sql.gz 7.53 MB
[2] : mysite_dev_2013-08-26T08-00-00_database.sql.gz 7.45 MB
[3] : mysite_dev_2013-08-25T08-00-00_database.sql.gz 7.49 MB
[4] : mysite_dev_2013-08-24T08-00-00_database.sql.gz 7.64 MB
[5] : mysite_dev_2013-08-24T07-01-15_database.sql.gz 7.33 MB
1
Overwrite this database with dev.site-uuid? (y/n): y
```

As it is right now, gunzip needs to be executable at the command line to decompress the backup. I added a TODO comment since I'm not sure what the most compatible method to handle that is.

A less critical note, but it would be helpful if "Overwrite this database " actually named the db it was writing over. I haven't spent a ton of time with Drush, but it should be easy to figure out with the sql sync code.

I successfully tested locally on OSX within an environment (not aliased) as well as with a local alias. Theoretically if the code was on our Pantheon environment, I should be able to load one of those environments from a backup with the same command.