-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSO_Backup.sh
More file actions
60 lines (49 loc) · 1.53 KB
/
DSO_Backup.sh
File metadata and controls
60 lines (49 loc) · 1.53 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
##################################################
### ############
### Created by Mateusz Domin ############
### contakt biuro@dso.biz.pl ############
### WEB https://dso.biz.pl ############
### ############
### date create 11.08.2018r ############
### ############
##################################################
### FTP login credentials below ###
FTPU="user_ftp"
FTPP="pass_ftp"
FTPS="127.0.0.1"
### MySQL login credentials below ###
MySQLU="root"
MySQLP="pass"
MySQLDB="db_name"
### Local user
USER="itm"
PARH_SH="/opt/dso_backup"
### Date created backup ###
NOW=$(date +"%d_%m_%Y_%H_%M_%S")
### Days to check old backups | default +3 ###
DAYS=+3
### Directories and files ###
BACKUP_FOLDER="$PARH_SH/data"
DATA_FOLDER="/home"
FTP_DIRECTORY="/backup/"
ls -la $DATA_FOLDER
BD_FILE="$DATA_FOLDER/Backup_dso_DB_$NOW.sql"
DATA_FILE_NAME="Backup_dso_$NOW.tar.gz"
DATA_FILE="$BACKUP_FOLDER/$DATA_FILE_NAME"
### MySQL Dump
touch $BD_FILE
mysqldump --user=$MySQLU --password=$MySQLP --default-character-set=utf8 $MySQLDB > $BD_FILE ### | gzip > $BD_FILE
chown $MySQLU "$BD_FILE"
find "$DATA_FOLDER" -name Backup_dso_DB_* -mtime $DAYS -exec rm {} \;
tar -cvzf $DATA_FILE $DATA_FOLDER
cd $BACKUP_FOLDER
export GLOBIGNORE=$DATA_FILE_NAME;rm -rf *;export GLOBIGNORE=;
lftp -f "
open $FTPS
user $FTPU $FTPP
lcd $BACKUP_FOLDER
mirror --reverse --delete --verbose $BACKUP_FOLDER $FTP_DIRECTORY
bye
"
exit 0