Thẻ: Bash

  • Bash backup hệ thống

    Tự động remove file: #!/bin/bash cd /home/backup/databases/ && (ls database-* -t|head -n 100;ls database-*)|sort|uniq -u|xargs rm Backup database từ server khác đã add ssh key: #!/bin/bash ssh user@example.com “mysqldump –column-statistics=0 {DATABASE_NAME} -h 127.0.0.1 –port=3306 -u{MYSQL_USER_NAME}” > ~/backup/databases/database-$(date ‘+%d-%m-%Y_%H:%M:%S’).sql Tạo crontab: 10 * * * * /home/backup/backup-database.sh 10 23 * * * /home/backup/auto-remove.sh Backup storage Bỏ…