Skip to content

Instantly share code, notes, and snippets.

@cristopher-rodrigues
Last active December 2, 2015 13:09
Show Gist options
  • Save cristopher-rodrigues/3c731b673ae22c540c0c to your computer and use it in GitHub Desktop.
Save cristopher-rodrigues/3c731b673ae22c540c0c to your computer and use it in GitHub Desktop.
Mongo copy last data (SIMPLE BKP)

Create script on server

/root/mongo_bkp.sh

rm -rf /root/dump* && mongodump && tar -cvf dump.tar dump/

Exec script

ssh user@machine /root/mongo_bkp.sh

Copy data to local

scp -r user@machine:/root/dump.tar dump.tar

Optional alias

~/.zshrc

alias mongo.bkp.sales="ssh user@machine /root/mongo_bkp.sh && scp -r user@machine:/root/dump.tar dump.tar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment