Skip to content

Latest commit

聽

History

History
48 lines (33 loc) 路 1.46 KB

backup-and-restore.md

File metadata and controls

48 lines (33 loc) 路 1.46 KB
title Backup & Database Migration Guide
description Automated MongoDB snapshot creation, archive extraction, and migration between host servers.

馃捑 Backup & Database Migration Guide

This guide covers backing up your MongoDB database, restoring data, and migrating between servers.


馃摝 Backing Up Your Database

To create a complete snapshot of all profiles, accounts, posts, timelines, and scrape history:

1-Line Backup Command

docker exec -t instagram_saved_posts_mongo mongodump --db instagram --archive=/data/db/backup_$(date +%Y%m%d_%H%M%S).archive

Copying the Backup to Your Host Machine

docker cp instagram_saved_posts_mongo:/data/db/backup_latest.archive ./backup_latest.archive

馃攧 Restoring from Backup

To restore an archive into a running container:

# 1. Copy the archive into the container
docker cp ./backup_latest.archive instagram_saved_posts_mongo:/data/db/backup_restore.archive

# 2. Restore into MongoDB
docker exec -t instagram_saved_posts_mongo mongorestore --db instagram --archive=/data/db/backup_restore.archive --drop

馃殮 Migrating to a New Server

  1. Run the backup command on your old server.
  2. Transfer backup_latest.archive and docker-compose.yml to the new server via scp or rsync.
  3. Run docker compose up -d on the new server.
  4. Run the restore command on the new server.
  5. All profiles, session cookies, and post archives will be restored seamlessly!