标签:backup echo roo tla rem nba serve oca 登录
LocalBackDir=/var/opt/gitlab/backups
RemoteBackDir=/root/gitlab_backup
RemoteUser=root
RemoteIP=(备份服务器B的地址,请你自行修改)
DATE=date +"%Y-%m-%d"
LogFile=$LocalBackDir/log/$DATE.log
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
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
gitlab自动备份脚本auto_backup_to_remote
标签:backup echo roo tla rem nba serve oca 登录
原文地址:https://www.cnblogs.com/Doc-Yu/p/12085025.html