divio / divio-cli

Command line interface to the Divio Cloud (formerly aldryn-client)
http://control.divio.com
Other
21 stars 19 forks source link

feature: add support for database upload from the working directory #196

Closed vinitkumar closed 7 years ago

vinitkumar commented 7 years ago

This PR adds the support for uploading the database dump directly from the working directory. The user needs to provide the website id where the database needs to be uploaded and a valid dump file that could be restored.

In order to make sure the db dump is compatible, create a dump using the following command:

pg_dump --no-privileges --no-acl --no-owner -d cms > cms_dump.sql

Now, in order to upload dump, run this command from the directory where the file exists.

 divio project --id=37457 push db --dumpfile=cms_dump.sql

This will upload the file after compressing it and restore it in the same way it does while uploading db from docker container for the project.

Signed-off-by: Vinit Kumar vinit.kumar@socialschools.nl

vinitkumar commented 7 years ago

@Chive please review this one.

vinitkumar commented 7 years ago

@Chive I had removed the asserts from this PR. Also, archive_wd is the directory where the dump file exists as I didn't wanted it to do anything with the project_home.

vinitkumar commented 7 years ago

@Chive I have made the suggested changes, the upload is behind a flag now. It requires a project id to be passed as well as the file needs to be in the current directory where the command is executed. Hopefully, if it good enough to be merged. I have already tested all the edge case. Please check it once at your end too. If you need any changes, let me know!

Thanks!