-
Notifications
You must be signed in to change notification settings - Fork 14
/
macosbakone.sh
executable file
·39 lines (37 loc) · 1.72 KB
/
macosbakone.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
#############################################################
###
### mm, .m .m, W
### ]""W, PW W"W " ][
### d['W W`]bWb W ][ ][ WW ]WWW
### ]WW ]W[ ]P T[ W ][W][ W ][
### T[ .W, ][ ][ W ][ ][ W ][
### ]mmW` d"b ]WmW`.mWm, WmW .mWm, ]bm
### ""` '" "`]["` '"""` '"` '"""` ""
### ][
###
###
### name: macosbak.sh
### function: bakup system
### date: 2017-03-17
### author: quanyechavshuo
### blog: http://3xp10it.cc
#############################################################
#macos系统备份脚本,备份产生一个文件,macosbak1.tgz为上一次备份的文件
# crontab -e like:
# m h dom mon dow command
#18 8 5 * * root bash ~/mytools/macosbak.sh
bakupdevice="/"
bakupfolder="/macosbak/"
bakupfile1="/macosbak/macosbak1.tgz"
if [ ! -d $bakupdevice ]; then
echo "bakupfolder not exist,the bakupdevice is not ready,check it"
elif [ -d $bakupdevice -a -d $bakupfolder ]; then
echo "bakupdevice is ok,bakupfolder exist"
if [ -f $bakupfile1 ]; then
rm $bakupfile1
fi
elif [ -d $bakupdevice -a ! -d $bakupfolder ]; then
echo "bakupdevice is ok,bakupfolder not exist"
mkdir $bakupfolder
fi
tar cvpzf $bakupfile1 --exclude=/macosbak --exclude=/Volumes --exclude="/Library/Application Support" --exclude=/Library/Caches --exclude=~/.cache --exclude=/private/var/log --exclude=~/.Trash --exclude="~/Documents/Virtual Machines.localized" --exclude=~/Downloads --exclude=~/Library/Caches --exclude=/private/var/tmp --exclude=/private/var/vm --exclude=/Users/Shared/Parallels /