From fdb91422354437c75e178d06449585adb3c83a19 Mon Sep 17 00:00:00 2001 From: santiagosayshey Date: Mon, 24 Jun 2024 07:39:05 +0930 Subject: [PATCH] del. Removed legacy restore / backup scripts --- scripts/backup.sh | 30 ------------------------------ scripts/restore.sh | 36 ------------------------------------ 2 files changed, 66 deletions(-) delete mode 100755 scripts/backup.sh delete mode 100755 scripts/restore.sh diff --git a/scripts/backup.sh b/scripts/backup.sh deleted file mode 100755 index 2fedf8a..0000000 --- a/scripts/backup.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Set the MongoDB connection URI -MONGO_URI="mongodb://localhost:27017" - -# Set the database name -DB_NAME="Dictionarry" - -# Set the path to the backups directory -BACKUPS_DIR="../backups" - -# Create the backups directory if it doesn't exist -mkdir -p $BACKUPS_DIR - -# Get the current date and time -CURRENT_DATE=$(date +%d_%b_%Y_%H%M) - -# Create a new backup file with "release" prefix and formatted date -BACKUP_FILE="$BACKUPS_DIR/release_dictionarry_backup_$CURRENT_DATE.archive" - -# Perform the database dump -mongodump --uri "$MONGO_URI" --db "$DB_NAME" --archive="$BACKUP_FILE" --gzip - -# Check if the backup was successful -if [ $? -eq 0 ]; then - echo "Database backup created successfully: $BACKUP_FILE" -else - echo "Error: Failed to create database backup." - exit 1 -fi \ No newline at end of file diff --git a/scripts/restore.sh b/scripts/restore.sh deleted file mode 100755 index 6bc3153..0000000 --- a/scripts/restore.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# Set the MongoDB connection URI -MONGO_URI="mongodb://localhost:27017" - -# Set the database name -DB_NAME="Dictionarry" - -# Set the path to the backups directory -BACKUPS_DIR="../backups" - -# Find the latest backup file with "release" prefix -LATEST_BACKUP=$(ls -t "$BACKUPS_DIR"/release_dictionarry_backup_*.archive | head -1) - -# Check if a backup file was found -if [ -z "$LATEST_BACKUP" ]; then - echo "Error: No backup file found with 'release' prefix." - exit 1 -fi - -# Extract the date from the latest backup filename -BACKUP_DATE=$(echo "$LATEST_BACKUP" | sed -E 's/.*backup_(.*)\.archive/\1/') - -# Drop the existing database -mongosh "$MONGO_URI" --eval "db.getSiblingDB('$DB_NAME').dropDatabase()" - -# Restore the latest backup -mongorestore --uri "$MONGO_URI" --archive="$LATEST_BACKUP" --gzip - -# Check if the restore was successful -if [ $? -eq 0 ]; then - echo "Database restored successfully from backup dated: $BACKUP_DATE" -else - echo "Error: Failed to restore database." - exit 1 -fi \ No newline at end of file