tasks:restore
sudo apt-get install davfs2 -y mkdir /media/webdav mkdir ~/restore mount -t davfs https://remotesite.com/remote.php/webdav/backup /media/webdav
Найти РК файлов начиная с последней полной и скопировать их
find /media/webdav -name '*files*' -mtime -$(( ( $(date +'%s') - $(date --date 'last Saturday' +'%s') )/60/60/24 )) -exec cp -p {} ~/restore \;
Найти РК баз новее 24 часов и скопировать их
find /media/webdav -name '*sql*' -mtime -1 -exec cp -p {} ~/restore \;
http://stackoverflow.com/questions/4946785/how-to-find-the-difference-in-days-between-two-dates
http://stackoverflow.com/questions/5241625/find-and-copy-files
http://stackoverflow.com/questions/1015678/linux-most-recent-file-in-a-directory
for encrypted in ~/restore/*.aes ; do [ -f $encrypted ] && openssl enc -d -aes-256-cbc -in $encrypted -out $encrypted.dec -k your_password ; done
https://wiki.openssl.org/index.php/Command_Line_Utilities
history -c && history -w
for f in *.gz.aes.dec; do mv ./"$f" "${f%gz.aes.dec}gz"; done
https://ss64.com/bash/rename.html
http://ashep.org/2010/osnovy-bash-cikly/
for f in ~/restore/*files*.gz ; do [ -f $f ] && tar -xzf $f -C / ; done
Restore DBs:
gzip -d ~/restore/*.sql.gz mysql -u root -p wordpress < ~/restore/*wordpress*.sql chown -R www-data:www-data /var/www/html mysqladmin -u root -p'abc' password '123456'
https://www.cyberciti.biz/faq/mysql-change-root-password/
https://codex.wordpress.org/Restoring_Your_Database_From_Backup
tasks/restore.txt · Последнее изменение: 30.07.2024 19:21 — 127.0.0.1