×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÁÄÁÄÔõÑùÔÚGitLabÖÐʵÏÖÔöÁ¿±¸·Ý

gitlabÊÇÒ»¸ö»ùÓÚgitµÄ´úÂëÍйÜƽ̨£¬ÔÚÈí¼þ¿ª·¢ºÍЭ×÷Öб»ÆÕ±éʹÓá£ÓÉÓÚ´úÂëµÄÖ÷ÒªÐÔ£¬±¸·ÝÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ»·½Ú£¬ÒÔ±ÜÃâÊý¾Ýɥʧ¡£ÔÚ±¸·ÝÖУ¬ÔöÁ¿±¸·Ý±ÈÍêÕû±¸·ÝÔ½·¢¸ßЧ£¬±¾ÎĽ«ÏÈÈÝÔõÑùÔÚgitlabÖÐʵÏÖÔöÁ¿±¸·Ý¡£

Ò»¡¢Ê²Ã´ÊÇÔöÁ¿±¸·Ý

ÔöÁ¿±¸·ÝÊÇÖ¸ÔÚÍêÕû±¸·ÝµÄ»ù´¡ÉÏ£¬½ö±¸·Ý×ÔÉϴα¸·ÝÒÔÀ´±¬·¢µÄ¸ü¸Ä¡£ÕâÖÖ±¸·ÝÒªÁì¿ÉÒÔ½ÚÔ¼´æ´¢¿Õ¼äºÍ±¸·Ýʱ¼ä¡£

¶þ¡¢GitLabµÄ±¸·ÝÔ­Àí

GitLabµÄ±¸·Ý½ÓÄÉGitµÄ±¸·ÝÔ­Àí£¬Ã¿¸öGit¿ÍÕ»¶¼ÓÐÒ»¸ö.gitĿ¼£¬ÆäÖÐÉúÑÄÁËGitµÄËùÓÐÐëÒªÐÅÏ¢ºÍÀúÊ·¼Í¼¡£Òò´Ë£¬±¸·ÝʵÖÊÉÏÊDZ¸·ÝÕâ¸öĿ¼¡£

Èý¡¢ÔõÑùʵÏÖÔöÁ¿±¸·Ý

ÔÚGitLabÖÐʵÏÖÔöÁ¿±¸·Ý£¬ÐèҪʹÓÃGit×Ô¼ºÌṩµÄһЩ¹¤¾ßºÍÏÂÁî¡£ÏÂÃæÎÒ½«ÏÈÈÝÔõÑùÔÚLinuxϵͳÖÐʵÏÖGitLabÔöÁ¿±¸·Ý¡£

×°ÖÃrsync¹¤¾ß

rsyncÊÇÒ»¸öÓÃÓÚÎļþͬ²½µÄ¹¤¾ß£¬Ëü¿ÉÒÔ½«ÍâµØÎļþÓëÔ¶³ÌÎļþͬ²½¡£ÔÚLinuxϵͳÖУ¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°ÖÃrsync¹¤¾ß¡£

sudo apt-get install rsync

µÇ¼ºó¸´ÖÆ

½¨ÉèÔöÁ¿±¸·Ý¾ç±¾

ÔÚGitLabЧÀÍÆ÷ÉÏ£¬¿ÉÒÔ½¨ÉèÒ»¸öÃûΪ”gitlab_backup.sh”µÄ±¸·Ý¾ç±¾£¬¸Ã¾ç±¾¿ÉÒÔÓÃÓÚ×Ô¶¯»¯GitLab±¸·Ý¡£ÒÔÏÂÊǾ籾µÄÄÚÈÝ¡£

#!/bin/bash

# ±¸·ÝĿ¼
BACKUP_DIR=/data/backups/gitlab
# GitLab×°ÖÃĿ¼
GITLAB_DIR=/opt/gitlab
# ±¸·ÝÎļþÃû
BACKUP_NAME=`date "+%Y%m%d"`"_gitlab_backup.tar"

# »ñÈ¡Éϴα¸·Ýʱ¼ä´Á
LAST_BACKUP_FILE=`ls -1 $BACKUP_DIR | tail -n 1`
if [ "$LAST_BACKUP_FILE" = "" ]; then
    LAST_BACKUP_TIMESTAMP=0
else
    LAST_BACKUP_TIMESTAMP=`date -d ${LAST_BACKUP_FILE%%"_gitlab_backup.tar"} "+%s"`
fi

# ½¨ÉèGitLab±¸·Ý
echo "Creating GitLab backup..."
$GITLAB_DIR/bin/gitlab-rake gitlab:backup:create

# ±¸·Ýб¬·¢µÄ±¸·Ý
NEW_BACKUP_FILE=`ls -1 $BACKUP_DIR | tail -n 1`
NEW_BACKUP_TIMESTAMP=`date -d ${NEW_BACKUP_FILE%%"_gitlab_backup.tar"} "+%s"`
if [ "$NEW_BACKUP_TIMESTAMP" -gt "$LAST_BACKUP_TIMESTAMP" ]; then
    echo "Backing up new GitLab backup..."
    rsync -v -r -e ssh $BACKUP_DIR/$NEW_BACKUP_FILE user@remote-server:$BACKUP_DIR/
fi

µÇ¼ºó¸´ÖÆ

¸Ã¾ç±¾Ê×ÏȽç˵Á˱¸·ÝĿ¼¡¢GitLab×°ÖÃĿ¼ºÍ±¸·ÝÎļþÃûµÈ²ÎÊý¡£È»ºó£¬Ëü»ñÈ¡Éϴα¸·ÝµÄʱ¼ä´Á£¬½¨ÉèGitLab±¸·Ý£¬²¢»ñȡеı¸·ÝÎļþÃûºÍʱ¼ä´Á¡£×îºó£¬Ê¹ÓÃrsync½«Ð±¸·ÝÎļþͬ²½µ½Ô¶³ÌЧÀÍÆ÷ÉÏ¡£

ÉèÖÃ׼ʱʹÃü

ΪÁËʵÏÖ×Ô¶¯Ö´Ðб¸·Ý¾ç±¾£¬¿ÉÒÔÉèÖÃÒ»¸ö׼ʱʹÃü¡£ÔÚLinuxϵͳÖУ¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉèÖÃÌìÌìÖ´ÐÐÒ»´Î±¸·Ý¡£

echo "0 0 * * * /bin/bash /data/backups/gitlab/gitlab_backup.sh" | sudo crontab -

µÇ¼ºó¸´ÖÆ

ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃǾͿÉÒÔÔÚGitLabÖÐʵÏÖÔöÁ¿±¸·Ý£¬²¢±£»¤ÎÒÃǵĴúÂë²»»áɥʧ¡£

ÒÔÉϾÍÊÇÁÄÁÄÔõÑùÔÚGitLabÖÐʵÏÖÔöÁ¿±¸·ÝµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ