From 8c87f7388f5689fc8b701a84fd981b523f3e0ea8 Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 16 Dec 2025 12:02:24 +0000 Subject: [PATCH] backup script added --- bash_scripts/backup.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 bash_scripts/backup.sh diff --git a/bash_scripts/backup.sh b/bash_scripts/backup.sh new file mode 100755 index 0000000..d51a55e --- /dev/null +++ b/bash_scripts/backup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + + +# Check to make sure the user has entered exactly two arguments. +if [ $# -ne 2 ] +then + echo "Usage backup.sh " + echo "Please try again." + exit 1 +fi + +# Check to see if rsync is installed +if ! command -v rsync > /dev/null 2>&1 +then + echo "This script requires rsync to be installed." + echo "Please use your distribution's package manager to install and try again." + exit 2 +fi + +# Capture the current date and store it to the format YYYY-MM-DD +current_date=$(date +%Y-%m-%d_%H-%M-%S) + +rsync_options="-avb --backup-dir $2/$current_date --delete " + +$(which rsync) $rsync_options $1 $2/current >> backup_$current_date.log