• 克隆项目并进入项目目录:git clone https://github.91chi.fun/https://github.com/Pricetx/backup.git;cd backup

  • 创建所需目录:mkdir -p /root/backups/temp/

  • 添加脚本可执行权限:chmod +x backup.sh

  • 编辑配置文件backup.cfg,注释写的很清楚,要配置的也不多,注意:最好给该配置文件配置权限为044,因为里面存放了加密密码

    ### BACKUP CONFIGURATION ###
    
    # KEEP THE PASSWORD SAFE. It is HIGHLY recommended to chmod 400 this file so 
    # that other users can not read it
    
    # To decrypt backups made by this script, run the following command:
    # openssl enc -aes256 -in [encrypted backup] -out decrypted_backup.tgz -pass pass:[backup password] -d -md sha1
    #解密命令:openssl enc -aes256 -in 加密文件名.tgz.enc -out decrypted_backup.tgz -pass pass:解密密码 -d -md sha1
    
    ## Edit the entries below to match your needs ##
    
    # The password used to encrypt the backup
    # NOTE: MAKE SURE THAT YOU CHMOD THIS FILE TO 400 TO AVOID UNAUTHORISED ACCESS
    BACKUPPASS="mysecurepassword"
    
    # Directory to store backups
    #存放本机本分文件路径
    LOCALDIR="/root/backups/"
    
    # Temporary directory used during backup creation
    TEMPDIR="/root/backups/temp/"
    
    # File to log the outcome of backups
    LOGFILE="/root/backups/backup.log"
    
    # Number of days to store daily local backups
    LOCALAGEDAILIES="7"
    
    # Number of days to store daily remote backups
    REMOTEAGEDAILIES="7"
    
    # Number of days to store weekly local backups
    LOCALAGEWEEKLIES="28"
    
    # Number of days to store weekly remote backups
    REMOTEAGEWEEKLIES="28"
    
    # Number of days to store monthly local backups
    LOCALAGEMONTHLIES="183"
    
    # Number of days to store monthly remote backups
    REMOTEAGEMONTHLIES="183"
    
    # IP / hostname of the server to store remote backups
    #远程主机IP,即你要把备份文件传到哪台服务器上
    REMOTESERVER="REMOTE_SERVER_HERE"
    
    # SSH port of remote server
    REMOTEPORT=22
    
    # User to use with SSH (public key needs to be installed on the remote server)
    #远程主机用户名(该配置文件中没有配置密码,是因为通过公钥连接的,可以使用ssh-copy-id 用户名@主机名,将公钥放在远程主机上)
    REMOTEUSER="REMOTE_USER_HERE"
    
    # Path to store the remote backups
    #远程主机存放备份文件路径,注意要保证路径存在,且权限正确
    REMOTEDIR="/BACKUP/PATH/ON/REMOTE/SYSTEM/"
    
    # Limit bandwidth used by SCP, in Kbit/s. Set to 0 for unlimited.
    SCPLIMIT=0
    
    # OPTIONAL: If you want MySQL to be backed up, enter the root password below
    #如果要备份数据库的话,填写mysql数据库密码
    ROOTMYSQL=""
    
    # Below is a list of files and directories that will be backed up in the tar
    # backup. To add an entry, add a new line with the same format
    #需要备份的文件路径
    BACKUP+=("/root/backup.cfg")
    BACKUP+=("/etc/")
    
    # Files and directories to exclude from tar backups
    # To add an entry, add a new line with the same format
    # NOTE: DO NOT LEAVE A TRAILING SLASH ON LINUX - IT WILL CAUSE IT TO NOT WORK
    #需要排除的文件路径
    EXCLUDE+=("")
    
    # Below is a list of files and directories that will be backed up in the rsync
    # backup. To add an entry, add a new line with the same format
    # NOTE: DO NOT LEAVE A TRAILING SLASH - IT WILL CAUSE IT TO NOT WORK
    RSYNCDIR+=("")
    

原文地址:http://www.cnblogs.com/steinven/p/16824167.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性