-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdomain.sh
31 lines (23 loc) · 833 Bytes
/
domain.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
#!/bin/bash
# Configuration de base
DATE=$(date +"%Y-%m-%d")
HOUR=$(date +"%H%p")
# Dossier où se trouve mes domaines
DOMAINS_FOLDER="/apps"
# Dossier où sauvegarder les backups (créez le d'abord!)
BACKUP_DIR="/home/backup/domains"
# Nombre de jours à garder les dossiers (seront effacés après X jours)
RETENTION=2
# Create a new directory into backup directory location for this date
mkdir -p $BACKUP_DIR/$DATE/$HOUR
# Backup domains
for folder in $(find ${DOMAINS_FOLDER} -mindepth 1 -maxdepth 1 -type d)
do
cd $(dirname ${folder})
tar czpf ${BACKUP_DIR}/$DATE/$HOUR/$(basename ${folder}).tar.gz $(basename ${folder})
cd - > /dev/null
done
# Remove files older than X days
find $BACKUP_DIR -maxdepth 1 -mtime +$RETENTION -exec rm -rf {} \;
# Sync Mega Cloud
mega-sync -dsr /home/backup backup