From ea196a24b57ccfed3bb9711ba8cc02d0270d059b Mon Sep 17 00:00:00 2001 From: alpcentaur Date: Tue, 19 Mar 2024 14:29:05 +0000 Subject: [PATCH] first commit --- README.md | 4 ++++ rad_extract.bash | 26 ++++++++++++++++++++++++++ rad_incect.bash | 3 +++ 3 files changed, 33 insertions(+) create mode 100644 README.md create mode 100644 rad_extract.bash create mode 100644 rad_incect.bash diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f68502 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ + + +RAD (recursive after date) is a bash script for keeping two big folders in sync, only copying the last changes after a certain date. +Originally it was created to keep a Nextcloud Twin in sync to a running Nextcloud Instance, for fast recovery. diff --git a/rad_extract.bash b/rad_extract.bash new file mode 100644 index 0000000..c068879 --- /dev/null +++ b/rad_extract.bash @@ -0,0 +1,26 @@ +#!/bin/bash + +# create a backup folder in the data directory where you want to recover files, go into the backup folder, and have dir data in same parent dir + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") + +find ../data -type f -newermt '1 Feb' -print0 | while read -d $'\0' file +do + dir=`dirname "$file"` + #filename=`basename "$file"` + + # dir new without going out two points + dir_new=${dir:3} + + mkdir -p "$dir_new" + + echo "duplicating $file with its directory.." + + cp -p "$file" "$dir_new" + + # also touch does the -p option, but better -p + #touch -r "$file" "$dir_new/$filename" + + +done diff --git a/rad_incect.bash b/rad_incect.bash new file mode 100644 index 0000000..2ede625 --- /dev/null +++ b/rad_incect.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +cp -r data ../