Merge pull request #8 from tinpee/master

Add empty db folder, fix readme
This commit is contained in:
John Washam
2016-10-19 17:34:29 -07:00
committed by GitHub
3 changed files with 6 additions and 7 deletions

View File

@@ -67,21 +67,21 @@ __Make sure you already installed [docker](https://www.docker.com)__
__If you already had a backup file `cards.db`. Run following command:__ __If you already had a backup file `cards.db`. Run following command:__
*Note: We don't need to rebuild image, just delete old container if you already built.* *Note: We don't need to rebuild image, just delete old container if you already built.*
`docker run -d -p 8000:8000 --name cs-flash-cards -v :<path_to_folder_contains_cards_db>:/src/db cs-flash-cards` `docker run -d -p 8000:8000 --name cs-flash-cards -v :<path_to_folder_contains_cards_db>:/src/db cs-flash-cards`.
`<path_to_folder_contains_cards_db>`: is the full path contains `cards.db` `<path_to_folder_contains_cards_db>`: is the full path contains `cards.db`.
Example: `/home/tinpee/cs-flash-cards/db`, and `cards.db` is inside this folder. Example: `/home/tinpee/cs-flash-cards/db`, and `cards.db` is inside this folder.
For convenient, if you don't have `cards.db`, this container will auto copy a new one from `cards-jwasham.db`. So you don't need to `initdb` For convenient, if you don't have `cards.db`, this container will auto copy a new one from `cards-jwasham.db`. So you don't need to `initdb`.
__How to backup data ?__ ### How to backup data ?
We just need store `cards.db` file, and don't need any sql command. We just need store `cards.db` file, and don't need any sql command.
- If you run container with `-v <folder_db>:/src/db` just go to `folder_db` and store `cards.db` anywhere you want. - If you run container with `-v <folder_db>:/src/db` just go to `folder_db` and store `cards.db` anywhere you want.
- Without `-v flag`. Type: `docker cp <name_of_container>:/src/db/cards.db /path/to/save` - Without `-v flag`. Type: `docker cp <name_of_container>:/src/db/cards.db /path/to/save`
__How to restore data ?__ ### How to restore data ?
- Delete old container (not image): `docker rm cs-flash-cards` - Delete old container (not image): `docker rm cs-flash-cards`
- Build a new one with `-v flag`: - Build a new one with `-v flag`:
`docker run -d -p 8000:8000 --name cs-flash-cards -v :<path_to_folder_contains_cards_db>:/src/db cs-flash-cards` `docker run -d -p 8000:8000 --name cs-flash-cards -v <path_to_folder_contains_cards_db>:/src/db cs-flash-cards`
- Voila :) - Voila :)
*Happy learning!* *Happy learning!*

0
db/.gitkeep Normal file
View File

View File

@@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
if [ ! -f /src/db/cards.db ]; then if [ ! -f /src/db/cards.db ]; then
mkdir -p /src/db
cp cards-jwasham.db /src/db/cards.db cp cards-jwasham.db /src/db/cards.db
fi fi