Skip to content

Instantly share code, notes, and snippets.

@catogonzalez
Created August 15, 2019 23:00
Show Gist options
  • Save catogonzalez/686eef3b729247bf57fcb974b28ce738 to your computer and use it in GitHub Desktop.
Save catogonzalez/686eef3b729247bf57fcb974b28ce738 to your computer and use it in GitHub Desktop.
Git hooks to automate database snapshots using Stellar
#!/bin/sh
# This is to automate the process of db snapshots with
# https://github.com/fastmonkeys/stellar
# read current git branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD )
if stellar list | grep $BRANCH; then
# checkout the existing db snapshot
stellar restore $BRANCH
else
# create a new snapshot from master
echo New db snapshot from master
stellar restore master
stellar snapshot $BRANCH
fi
#!/bin/sh
# This is to automate the process of db snapshots with
# https://github.com/fastmonkeys/stellar
# read current git branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD )
if stellar list | grep $BRANCH; then
# update the existing snapshot
stellar replace $BRANCH
else
echo NOT FOUND: $BRANCH
fi
@catogonzalez
Copy link
Author

These are a couple of git hooks that help automate the switching of databases in development using Stellar.

So, whenever you switch to a branch using git checkout my-branch you will have created (or restored) a database snapshot with stellar snapshot $BRANCH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment