-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransformToBackInTime.sh
More file actions
50 lines (37 loc) · 1.46 KB
/
transformToBackInTime.sh
File metadata and controls
50 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
RSYNC=/usr/bin/rsync
RSYNC_ARGS="--protect-args --recursive --times --devices --specials \
--hard-links --human-readable --links --acls --perms \
--group --owner --no-inc-recursive -v --exclude-from=exclude.txt"
SRC="/smth/like/TimeMachine_BACKUP" # ADJUST!!!
TAIL_SRC="Macintosh HD/Users/"
DST="/where/your/backintime/backups/are" # ADJUST!!!
TAIL_DEST="backup/home"
BDIR="Backups.backupdb"
MACHINE_NAME=$(ls -d $SRC/$BDIR/*)
MACHINE_NAME=$(basename "$MACHINE_NAME")
RUN_RSYNC="$RSYNC $RSYNC_ARGS"
for folder in $SRC/$BDIR/$MACHINE_NAME/*; do
echo "Add folder $folder to queue"
SRC_DATES="$SRC_DATES $(basename "$folder")"
done
first=true
for curr in $SRC_DATES; do
FULL_SRC="$SRC/$BDIR/$MACHINE_NAME/$curr/$TAIL_SRC"
# really ugly code -- no idea how to make it better
a=(`echo $curr | sed -e 's/[:-]/ /g'`)
FULL_DST="$DST/${a[0]}${a[1]}${a[2]}-${a[3]}-000/$TAIL_DEST"
mkdir -p $FULL_DST
echo "Sync $curr folder"
echo "You can find progress in log file sync_log_$curr"
if [ "$first" = true ]; then
echo $RUN_RSYNC "${FULL_SRC}" "${FULL_DST}" 2\>\&1 \> sync_log_$curr
$RUN_RSYNC "${FULL_SRC}" "${FULL_DST}" 2>&1 > sync_log_$curr
prev="${FULL_DST}"
first=false
continue
fi
echo $RUN_RSYNC --link-dest=$prev "${FULL_SRC}" "${FULL_DST}" 2\>\&1 \> sync_log_$curr
$RUN_RSYNC --link-dest=$prev "${FULL_SRC}" "${FULL_DST}" 2>&1 > sync_log_$curr
prev="${FULL_DST}"
done