Skip to content

realgolfgames/backup-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB Backup and Import Scripts

This repository provides Bash scripts for automating the export and import of data from a MongoDB collection. The backup script organizes backups based on the current year, month, and day, while the import script prompts the user to enter the file path of the backup file for importing.

Prerequisites

Before using the scripts, make sure to:

  • Have MongoDB installed.
  • Set up a MongoDB URI and store it in the .env file.
  • Create a .env file with the following content:
  MONGODB_URI="your_mongodb_uri_here"

Backup Script Usage

  1. Clone the repository:
git clone https://github.com/realgolf/backup-script.git
  1. Navigate to the script directory:
cd mongodb-backup
  1. Make the backup script executable:
chmod +x backup.sh
  1. Run the backup script:
./backup.sh

This will export data from the specified MongoDB collection, create folders for the current year, month, and day, and store the backup file with a timestamp in the format HH-MM-SS.

Import Script Usage

  1. Navigate to the script directory:
cd mongodb-backup
  1. Make the import script executable:
chmod +x import.sh
  1. Run the import script:
./import.sh

This will prompt you to enter the file path of the backup file, and then it will import the data into the specified MongoDB collection.

File Organization

Backups are organized in the following folder structure:

backups/
|-- YEAR/
|   |-- MONTH/
|       |-- DAY/
|           |-- HH-MM-SS.json

License

This project is licensed under the MIT License.