-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackup.sh
executable file
·45 lines (29 loc) · 1.04 KB
/
Backup.sh
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
#!/bin/bash
# Install homebrew's version of rsync
brew install rsync
#We will save path to backup file in variable
backupf='./backup-files.txt'
#Next line just prints message
echo "Shell Script Backup Your Files / Directories Using rsync"
#next line check if entered value is not null, and if null it will reask user to enter Destination Path
while [ x$destpath = "/Volumes/Vault/MacBook" ]; do
#next line prints what userd should enter, and stores entered value to variable with name destpath
read -p "Destination Folder : " destpath
#next line finishes while loop
done
# Make newlines the only separator.
IFS=$'\n'
#Next line will start reading backup file line by line
for path in $(cat $backupf)
#and on each line will execute next
do
#print message that file/dir will be copied
printf "Copying ${path}... "
cd ~/
# The magic happens here—copy via rsync file/dir to destination. Add -nv for dry runs/debugging.
rsync -rtlXR --progress "$path" "$destpath"
#this line just print done
echo "DONE."
#end of reading backup file
done
unset IFS