-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmongoexport.sh
executable file
·27 lines (22 loc) · 1.79 KB
/
mongoexport.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
source settings.sh
rm $SQLITEDBNAME csv/*.csv
mongoexport --uri="${MONGOURI}" --collection=attachments --type=csv --fieldFile=fields/attachments-fields.txt --out=csv/attachments.csv
mongoexport --uri="${MONGOURI}" --collection=attachments.files --type=csv --fieldFile=fields/attachments.files-fields.txt --out=csv/attachments.files.csv
mongoexport --uri="${MONGOURI}" --collection=avatars --type=csv --fieldFile=fields/avatars-fields.txt --out=csv/avatars.csv
mongoexport --uri="${MONGOURI}" --collection=avatars.files --type=csv --fieldFile=fields/avatars.files-fields.txt --out=csv/avatars.files.csv
mongoexport --uri="${MONGOURI}" --collection=cfs.attachments.filerecord --type=csv --fieldFile=fields/cfs.attachments.filerecord-fields.txt --out=csv/cfs.attachments.filerecord.csv
mongoexport --uri="${MONGOURI}" --collection=cfs.avatars.filerecord --type=csv --fieldFile=fields/cfs.avatars.filerecord-fields.txt --out=csv/cfs.avatars.filerecord.csv
mongoexport --uri="${MONGOURI}" --collection=cfs_gridfs.attachments.files --type=csv --fieldFile=fields/cfs_gridfs.attachments.files-fields.txt --out=csv/cfs_gridfs.attachments.files.csv
mongoexport --uri="${MONGOURI}" --collection=cfs_gridfs.avatars.files --type=csv --fieldFile=fields/cfs_gridfs.avatars.files-fields.txt --out=csv/cfs_gridfs.avatars.files.csv
echo ".mode csv
.import csv/attachments.csv attachments
.import csv/attachments.files.csv attachments.files
.import csv/avatars.csv avatars
.import csv/avatars.files.csv avatars.files
.import csv/cfs.attachments.filerecord.csv cfs.attachments.filerecord
.import csv/cfs.avatars.filerecord.csv cfs.avatars.filerecord
.import csv/cfs_gridfs.attachments.files.csv cfs_gridfs.attachments.files
.import csv/cfs_gridfs.avatars.files.csv cfs_gridfs.avatars.files
.quit" | sqlite3 $SQLITEDBNAME
rm csv/*.csv