-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud_backup.sh
More file actions
26 lines (16 loc) · 753 Bytes
/
Copy pathcloud_backup.sh
File metadata and controls
26 lines (16 loc) · 753 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
#!/bin/bash
#you will need SSH Key-Based Authentication
#conf files backup
tar czpf conf-`date +%Y_%m_%d`$.tgz /etc/postfix /etc/httpd /etc/foo
# mysql backup - create a user for backup with SELECT,EVENT,RELOAD,SHOW TABLES,LOCK TABLES privileges instead of root user
mysqldump -u backup -pPASSWD --all-databases > db-`date +%Y_%m_%d`$.sql
tar czpf db-`date +%Y_%m_%d`$.tgz db-`date +%Y_%m_%d`$.sql
rm -fr db-`date +%Y_%m_%d`$.sql
#postfix users mailbox backup
tar czpf mail-`date +%Y_%m_%d`$.tgz /var/spool/mail/vhost/foo
#backup http files
tar czpf http-`date +%Y_%m_%d`$.tgz /srv/http /home/user/foo
#rsync into storage
rsync -Cravzp -e 'ssh -p 22' *-`date +%Y_%m_%d`$.tgz user@192.168.0.2:/mnt/backup/foo
rm -fr *-`date +%Y_%m_%d`.tgz
exit