Contents
  1. 1. weekly backup script

weekly backup script

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
# vim /etc/backup/backupwk.sh
#!/bin/bash
# ====================================================================
# user input backup location
# basedir=backup dir
basedir=/backup/weekly

# ====================================================================
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH
export LANG=C

# backup folders
#named=$basedir/named
#postfixd=$basedir/postfix
#vsftpd=$basedir/vsftp
sshd=$basedir/ssh
#sambad=$basedir/samba
wwwd=$basedir/wwwd
#others=$basedir/others
userinfod=$basedir/userinfo
# check if the file exists, if didn't create a dir
for dirs in $sshd $wwwd $userinfod
do
[ ! -d "$dirs" ] && mkdir -p $dirs
done

# 1. service config file
#cp -a /var/named/chroot/{etc,var} $named
#cp -a /etc/postfix /etc/dovecot.conf $postfixd
#cp -a /etc/vsftpd/* $vsftpd
cp -a /etc/ssh/* $sshd
#cp -a /etc/samba/* $sambad
cp -a /etc/my.cnf $wwwd
cp -a /application/nginx/conf/nginx.conf $wwwd

cd /application
tar -jpc -f $wwwd/tomcat.tar.bz2 tomcat
tar -jpc -f $wwwd/nginx.tar.bz2 nginx

# 2. about user par
cp -a /etc/{passwd,shadow,group} $userinfod
cd /var/spool
tar -jpc -f $userinfod/mail.tar.bz2 mail
cd /var/spool
tar -jpc -f $userinfod/cron.tar.bz2 cron at

Every Sun 3.30 run weekly backup script:

1
2
# vim /etc/crontab
30 3 * * 0 root /backup/backupwk.sh
Contents
  1. 1. weekly backup script