zoukankan      html  css  js  c++  java
  • gitlab自动备份脚本auto_backup_to_remote

    #!/bin/bash
    
    # gitlab 服务器备份路径
    LocalBackDir=/var/opt/gitlab/backups
    
    # 远程备份服务器 gitlab备份文件存放路径
    RemoteBackDir=/root/gitlab_backup
    
    # 远程备份服务器 登录账户
    RemoteUser=root
    
    # 远程备份服务器 IP地址
    RemoteIP=(备份服务器B的地址,请你自行修改)
    
    #当前系统日期
    DATE=`date +"%Y-%m-%d"`
    
    #Log存放路径
    LogFile=$LocalBackDir/log/$DATE.log
    
    # 查找 gitlab本地备份目录下 时间为60分钟之内的,并且后缀为.tar的gitlab备份文件
    BACKUPFILE_SEND_TO_REMOTE=$(find $LocalBackDir -type f -mmin -60  -name '*.tar*')
    
    #新建日志文件
    touch $LogFile
    
    #追加日志到日志文件
    echo "Gitlab auto backup to remote server, start at  $(date +"%Y-%m-%d %H:%M:%S")" >>  $LogFile
    echo "---------------------------------------------------------------------------" >> $LogFile
    
    # 输出日志,打印出每次scp的文件名
    echo "---------------------The file to scp to remote server is: $BACKUPFILE_SEND_TO_REMOTE-------------------------------" >> $LogFile
    
    
    #备份到远程服务器
    scp $BACKUPFILE_SEND_TO_REMOTE $RemoteUser@$RemoteIP:$RemoteBackDir
    
    #追加日志到日志文件
    echo "---------------------------------------------------------------------------" >> $LogFile
    

    脚本

    #!/bin/bash
    #gitlab bakup_directory
    LocalBackDir=/var/opt/gitlab/backups
    #remote bakup_directory
    RemoteBackDir=/root/gitlab_backup
    #remote USER
    RemoteUser=root
    #remote IP
    RemoteIP=192.168.4.64
    #date
    DATE=`date +"%Y-%m-%d"`
    #log directory
    LogFile=$LocalBackDir/log/$DATE.log
    #Find the gitlab backup file with the suffix of .tar in the gitlab local backup directory for 60 minutes.
    BACKUPFILE_SEND_TO_REMOTE=$(find $LocalBackDir -type f -mmin -60  -name '*.tar*')
    #New log file
    touch $LogFile
    #Append log to log file
    echo "Gitlab auto backup to remote server, start at  $(date +"%Y-%m-%d %H:%M:%S")" >>  $LogFile
    echo "---------------------------------------------------------------------------" >> $LogFile
    #Output log, print out the file name of each scp
    echo "---------------------The file to scp to remote server is: $BACKUPFILE_SEND_TO_REMOTE-------------------------------" >> $LogFile
    #backup to remote server
    scp $BACKUPFILE_SEND_TO_REMOTE $RemoteUser@$RemoteIP:$RemoteBackDir
    #Append log to log file
    echo "---------------------------------------------------------------------------" >> $LogFile
    
  • 相关阅读:
    noi 2011 noi嘉年华 动态规划
    最小乘积生成树
    noi 2009 二叉查找树 动态规划
    noi 2010 超级钢琴 划分树
    noi 2011 阿狸的打字机 AC自动机
    noi 2009 变换序列 贪心
    poj 3659 Cell Phone Network 动态规划
    noi 2010 航空管制 贪心
    IDEA14下配置SVN
    在SpringMVC框架下建立Web项目时web.xml到底该写些什么呢?
  • 原文地址:https://www.cnblogs.com/Doc-Yu/p/12085025.html
Copyright © 2011-2022 走看看