Skip to content

Instantly share code, notes, and snippets.

View sethigoldy's full-sized avatar
🎯
Focusing

Inderjeet Singh sethigoldy

🎯
Focusing
View GitHub Profile
@sethigoldy
sethigoldy / base_backup.sh
Last active December 5, 2023 14:30
Incremental backups with mongodump and mongorestore
#!/bin/bash
New_DATE=$(date +%s)
mongodump -h localhost --port 27017 -o backups/base
Old_DATE=$(cat query.js | awk -F: '{print $5}' | cut -c 1-10)
awk -v old="$Old_DATE" -v new="$New_DATE" '{gsub("\"t\":" old ",", "\"t\":" new ",")} 1' query.js > temp.js && mv temp.js query.js