Skip to content

Commit

Permalink
Merge pull request #9 from masterpointio/feature/snaplet-restore-nopr…
Browse files Browse the repository at this point in the history
…ompt

feat: adds a restore:noprompt task
  • Loading branch information
Gowiem authored Nov 3, 2023
2 parents 41a8eea + 45a7794 commit 3f2f96a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion exports/Taskfile.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tasks:
echo -e "\n"
if [[ -n "{{.TASKIT_LOCAL_PATH}}" ]]; then
echo "Copying taskit from local path..."
rsync -rq --exclude=.git --exclude= {{.TASKIT_LOCAL_PATH}} .taskit
rsync -rq --exclude=.git --exclude= {{.TASKIT_LOCAL_PATH}}/ .taskit
else
echo "Downloading taskit from remote repo..."
git clone -b {{.TASKIT_BRANCH}} https://github.com/masterpointio/taskit.git .taskit/
Expand Down
20 changes: 18 additions & 2 deletions lib/snaplet/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,31 @@ tasks:

restore:
desc: Restores the given RESTORE_SNAPSHOT to the SNAPLET_TARGET_DATABASE_URL database.
prompt: This will wipe all of the data in the given SNAPLET_TARGET_DATABASE_URL. Are you sure?
silent: true
vars:
RESTORE_OPTIONS: '{{.RESTORE_OPTIONS | default ""}}'
RESTORE_SNAPSHOT: '{{.RESTORE_SNAPSHOT | default "latest"}}'
SNAPSHOT_PATH: .snaplet/snapshots/{{.SNAPSHOT_ENV}}/{{.RESTORE_SNAPSHOT}}
requires:
vars:
- SNAPLET_TARGET_DATABASE_URL
cmds:
- printf "\n\n👋 Restoring snapshot from {{.SNAPSHOT_PATH}}\n"
- snaplet snapshot restore {{.SNAPSHOT_PATH}}
- snaplet snapshot restore {{.RESTORE_OPTIONS}} {{.SNAPSHOT_PATH}}
- printf "\n\n💯 Restored snapshot from {{.SNAPSHOT_PATH}}\n"

restore:noprompt:
desc: Restores the given RESTORE_SNAPSHOT to the SNAPLET_TARGET_DATABASE_URL database.
silent: true
vars:
RESTORE_SNAPSHOT: '{{.RESTORE_SNAPSHOT | default "latest"}}'
SNAPSHOT_PATH: .snaplet/snapshots/{{.SNAPSHOT_ENV}}/{{.RESTORE_SNAPSHOT}}
requires:
vars:
- SNAPLET_TARGET_DATABASE_URL
cmds:
- task: restore
vars:
RESTORE_OPTIONS: --yes --no-progress
RESTORE_SNAPSHOT: "{{.RESTORE_SNAPSHOT}}"
SNAPSHOT_PATH: "{{.SNAPSHOT_PATH}}"

0 comments on commit 3f2f96a

Please sign in to comment.