bash-stuff/backup-image/sync-all-btime.sh

41 lines
973 B
Bash
Executable File

#/bin/bash
echo "Sync All Backups!";
if [ $# -eq 0 ]; then
echo "Usage: sync-all-btime.sh [o/n/i] <Target disk root path> [Source disk root path]";
echo "o : Replace if source older"
echo "n : Replace if source newer"
echo "i : Ignore backup times"
exit 2;
fi
ssrc="";
if [ -z $3 ]; then
ssrc="/mnt";
else
ssrc="$3";
fi
echo "Target disk root path: $2";
echo "Source disk root path: $ssrc";
if [[ "$1" == "o" ]]; then
echo "Targets will be replaced if source older.";
elif [[ "$1" == "n" ]]; then
echo "Targets will be replaced if source newer.";
else
echo "Targets will be replaced if different."
fi
if [[ "$4" != "ikwid" ]]; then
echo "Press Enter to Start...";
read;
fi
rval=0;
for cf in $ssrc/tabls/*; do
if [ -e "$cf" ] && [ -f "$cf" ]; then
./sync-btime.sh "$1" $(basename "$cf" ".tbl") "$2" "$ssrc" "ikwid";
if [ $? -ne 0 ]; then
echo "Sync failed: $cf";
rval=1;
fi
fi
done
echo "Finished!";
exit $rval;