From 70daa0e53f29afd78563b39c53217f84d861959f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Dec 2023 03:26:54 +0000 Subject: [PATCH] Read vars from external file --- logs/mongodb-status.log | 14 +++++++------- mongodb-backup.log | 1 - mongodb-backup.sh | 11 +++++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) delete mode 100644 mongodb-backup.log diff --git a/logs/mongodb-status.log b/logs/mongodb-status.log index 349aa81..84d7d76 100644 --- a/logs/mongodb-status.log +++ b/logs/mongodb-status.log @@ -1,10 +1,3 @@ -[2023-11-25 12:00:01] Success Main PID: 16903 (mongod) -[2023-11-25 12:05:01] Success Main PID: 16903 (mongod) -[2023-11-25 12:10:02] Success Main PID: 16903 (mongod) -[2023-11-25 12:15:02] Success Main PID: 16903 (mongod) -[2023-11-25 12:20:01] Success Main PID: 16903 (mongod) -[2023-11-25 12:25:01] Success Main PID: 16903 (mongod) -[2023-11-25 12:30:01] Success Main PID: 16903 (mongod) [2023-11-25 12:35:02] Success Main PID: 16903 (mongod) [2023-11-25 12:40:02] Success Main PID: 16903 (mongod) [2023-11-25 12:45:01] Success Main PID: 16903 (mongod) @@ -1630,3 +1623,10 @@ Changed ownership of /var/run/mongodb/mongod.pid to mongod:mongod [2023-12-01 02:40:01] Success Main PID: 3302 (mongod) [2023-12-01 02:45:01] Success Main PID: 3302 (mongod) [2023-12-01 02:50:02] Success Main PID: 3302 (mongod) +[2023-12-01 02:55:01] Success Main PID: 3302 (mongod) +[2023-12-01 03:00:01] Success Main PID: 3302 (mongod) +[2023-12-01 03:05:01] Success Main PID: 3302 (mongod) +[2023-12-01 03:10:02] Success Main PID: 3302 (mongod) +[2023-12-01 03:15:01] Success Main PID: 3302 (mongod) +[2023-12-01 03:20:02] Success Main PID: 3302 (mongod) +[2023-12-01 03:25:01] Success Main PID: 3302 (mongod) diff --git a/mongodb-backup.log b/mongodb-backup.log deleted file mode 100644 index a658555..0000000 --- a/mongodb-backup.log +++ /dev/null @@ -1 +0,0 @@ -Backup folder not set. Aborting script. diff --git a/mongodb-backup.sh b/mongodb-backup.sh index 9440e30..be7c63a 100755 --- a/mongodb-backup.sh +++ b/mongodb-backup.sh @@ -5,6 +5,17 @@ # BACKUP_MONGO_USER # BACKUP_MONGO_PASSWORD # BACKUP_MONGO_PATH +# Optionally, these variables can be specified in a separate file, config.sh instead. + + +# Get the directory of the script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Set the relative path to the config file +CONFIG_FILE="$SCRIPT_DIR/config.sh" +if [ -f "$CONFIG_FILE" ]; then + source "$CONFIG_FILE" +fi mongo_host="localhost" mongo_port="27017"