-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-rootfs.sh
More file actions
executable file
·35 lines (30 loc) · 996 Bytes
/
backup-rootfs.sh
File metadata and controls
executable file
·35 lines (30 loc) · 996 Bytes
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
#!/bin/bash
# username and password are sroted in ${root}/.my.cnf in section mysqldump
export NUM_BACKUPS=${NUM_BACKUPS:-2}
export SERVICE_NAME="rootfs"
export SRC_DIR="/"
export BACKUP_DIR=/links/sysbkp/${SERVICE_NAME}
export BACKUP_FILE=${SERVICE_NAME}.tgz
source /links/bin/lib/dbBackupFunctions.sh
function backupRootfs() {
echo "starting backup on $(date +%H:%M:%S)"
CMD="tar --selinux --acls --xattrs -cpf ${BACKUP_DIR}/${BACKUP_FILE} --directory / --use-compress-program=pigz --one-file-system --numeric-owner --exclude=proc/* --exclude=mnt/* --exclude=*/lost+found --exclude=tmp/* ."
echo ${CMD}
run-cmd "($CMD)"
echo "finished backup on $(date +%H:%M:%S)"
}
#main
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
TEST_MODE="false"
while getopts "ti" Option
do
case $Option in
t ) TEST_MODE="true";;
i ) initServiceFolder
esac
done
ls -l ${BACKUP_DIR}
echo NUM_BACKUPS=$NUM_BACKUPS
rotateFiles
backupRootfs
ls -l ${BACKUP_DIR}