aboutsummaryrefslogtreecommitdiffstats
path: root/SOURCE/CORE/core-backup.sh
diff options
context:
space:
mode:
authordanix <danix@danix.xyz>2023-04-03 18:42:43 +0200
committerdanix <danix@danix.xyz>2023-04-03 18:42:43 +0200
commit9eb02251c45d2b0d312b2c40f65f2f926bfb9a34 (patch)
tree4810195ee8747da09872369ae5b5443cb813e26e /SOURCE/CORE/core-backup.sh
parent07d42c7a11d817e19c4fb81dcdd1ae97ede991e8 (diff)
downloadbash-notes-9eb02251c45d2b0d312b2c40f65f2f926bfb9a34.tar.gz
bash-notes-9eb02251c45d2b0d312b2c40f65f2f926bfb9a34.zip
working on the backup and backup restore functionalities.
Diffstat (limited to 'SOURCE/CORE/core-backup.sh')
-rw-r--r--SOURCE/CORE/core-backup.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/SOURCE/CORE/core-backup.sh b/SOURCE/CORE/core-backup.sh
new file mode 100644
index 0000000..38569ab
--- /dev/null
+++ b/SOURCE/CORE/core-backup.sh
@@ -0,0 +1,44 @@
+function backup_data() {
+ BACKUPDIR="$1"
+ echo "backing up data in $BACKUPDIR"
+
+
+ if [ -d $BACKUPDIR ]; then
+ if [ $(/bin/ls -A $BACKUPDIR) ]; then
+ echo "$BACKUPDIR is not empty. Cannot continue"
+ exit
+ else
+ echo "$BACKUPDIR is ok. Continuing!"
+ fi
+ else
+ # BACKUPDIR doesn't exists
+ echo "$BACKUPDIR doesn't exists"
+ read -r -p "Do you want me to create it for you? (y/N) " ANSWER
+ case $ANSWER in
+ y|Y )
+ mkdir -p $BACKUPDIR
+ ;;
+ * )
+ echo "No changes made. Exiting"
+ exit
+ ;;
+ esac
+ fi
+ # ok, we have a backup directory
+ if [ -r $RCFILE ]; then
+ BCKUP_COMM=$(rsync -avz --progress ${RCFILE} ${BASEDIR}/* ${BACKUPDIR})
+ else
+ BCKUP_COMM=$(rsync -avz --progress ${BASEDIR}/* ${BACKUPDIR})
+ fi
+ # run the command
+ if [ "$BCKUP_COMM" ]; then
+ echo -e "BASE directory:\t\t$BASEDIR"
+ echo -e "BACKUP directory:\t$BACKUPDIR"
+ echo; echo "BACKUP COMPLETED"
+ fi
+}
+
+function backup_restore() {
+ echo "restoring backup"
+}
+