Concept to create backup/restore tool in Meteor?


#1

Now I want to create backup/restore tool in my project (local).
Ex: I have Customer Collection

[
   {_id: 1, name: Theara, gender: M, branchId: 001}
   {_id: 2, name: Vanna, gender: M, branchId: 001}
   {_id: 3, name: Davy, gender: F, branchId: 002}
   {_id: 4, name: Buntong, gender: M, branchId: 002}
   {_id: 5, name: Kimsan, gender: F, branchId: 003}
]

And the I want to create the form to backup/restore by branch office.

// Backup Form
<form>
   <select name='branchId'>
      <option value="all">All Branches</option>
      <option value="001">001</option>
      <option value="002">002</option>
   </select>
   <button type="submit">Backup</button>
</form>

Thanks all for helping.


#2

We looked into something like that when I was helping @sam with his blog package. It never took off (at least, not my pull request) so I created a shell script to do it. That way I could do backups on a cron job or run it from the command line, during a deploy script (via scp), etc.

Here’s the gist of it:

#!/bin/bash

DATE_STR=`date "+%m-%d-%y_%k-%M-%S"`;
echo "Backing up blog collectsion at $DATE_STR";
mongodump -h 127.0.0.1:3001 -d <yourDBName> -o ./$DATE_STR -c <Collection1>
mongodump -h 127.0.0.1:3001 -d <yourDBName> -o ./$DATE_STR -c <Collection2>
# Repeat for each collection you want backed up

cd $DATE_STR

tar -cf <tempFileName> meteor | gzip > <some.tar.gz filename>

In our case, this gets run before we deploy to production, for example.

I think there’s a similar mechanism for doing it inside Meteor - you could look at https://atmospherejs.com/hitchcott/app-dump, for example.

Good luck!


#3

Thanks for your reply.
I tried this package too. but it don’t support with Windows and I can’t custom with collections that we want.