Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
linux_faq:backup_all_mysql_databases_separate_files_to_ftp [2019/04/11 15:53] – admin | linux_faq:backup_all_mysql_databases_separate_files_to_ftp [2019/04/12 07:23] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Скрипт бекапа баз mysql ====== | ||
+ | Скрипт выполняет бекап всех баз, за исключением системных (**mysql**, | ||
+ | Для работы нужны **pigz** и **lftp**. | ||
+ | < | ||
+ | backup_name_prefix=mysql_databases | ||
+ | ftpserver=ftp.comp.local | ||
+ | username=ftp_user_login_name | ||
+ | password=ftp_user_pass | ||
+ | currentdate=$(date +%d-%m-%Y_%H_%M) | ||
+ | remote_www_dir=/ | ||
+ | backup_depth=10 | ||
+ | |||
+ | #Get list of directories with full encrypted backups | ||
+ | dirs=`echo "lftp -e 'set ssl: | ||
+ | dirs=(${dirs// | ||
+ | #check number of directories and delete oldest | ||
+ | if [[ ${#dirs[@]} -gt $backup_depth ]]; then | ||
+ | for ((i = $backup_depth; | ||
+ | { | ||
+ | echo "lftp -e 'set ssl: | ||
+ | } | ||
+ | fi | ||
+ | |||
+ | |||
+ | #Make temporary directory | ||
+ | mkdir --parents / | ||
+ | #Make archives | ||
+ | databases=`mysql --execute=' | ||
+ | for db in $databases | ||
+ | { | ||
+ | | ||
+ | } | ||
+ | #Make put archives to ftp | ||
+ | cd / | ||
+ | echo "lftp -e 'set ssl: | ||
+ | # Housekeeping | ||
+ | rm -Rf / | ||
+ | </ |