Progetto

Generale

Profilo

File » backup.sh

Andrea Belloni, 12-11-2015 19:20

 
1
#!/bin/bash
2

    
3
# Daily backup script
4

    
5
# Create some needed variable
6
day=$(date +%F)
7

    
8
folder="/usr/share/redmine"
9
file="/root/backup/$day-usr_share_redmine.tar.gz"
10
tar czf $file $folder
11

    
12
folder="/usr/share/wordpress"
13
file="/root/backup/$day-usr_share_wordpress.tar.gz"
14
tar czf $file $folder
15

    
16
folder="/var/lib/redmine"
17
file="/root/backup/$day-var_lib_redmine.tar.gz"
18
tar czf $file $folder
19

    
20
folder="/var/lib/mailman"
21
file="/root/backup/$day-var_lib_mailman.tar.gz"
22
tar czf $file $folder
23

    
24
folder="/var/www/wp-uploads"
25
file="/root/backup/$day-var_www_wp-uploads.tar.gz"
26
tar czf $file $folder
27

    
28
mysqldump --user=root --password="nonèquesta" --all-databases | gzip > $day-backup.sql.gz
29

    
30
# Remove backup files older than 4 days
31
find /root/backup/ -mtime +4 -name '*.gz' -exec rm {} \;
32

    
(1-1/2)