Gitlab and Confluence Backup solution V0.1

Source: Internet
Author: User

Note: Tomorrow's article, please first block for fast!

Gitlab Offsite Script Backup scheme

#     10.129.16.242                 10.129.16.243# ----------+-----------------------------+-------#            |                               |#     +-----+-----+                 +------+------+#     |      A     |                 |      B       |#     +-----------+                 +-------------+ #     gitlab server                 backups clinet## a and  b passed ssh authentication# this shell script will execute  on a server#!/bin/bash[ $ (id -u)  -ne 0 ] | |  exit 1save_days=5[ $? -eq 1 ] && exit 1gitlab_internal_ Backup_directory=/data/var/opt/gitlab/backups# if you have both wan ip and  lan ip, you can fill it with all, if you have one  ip, you can fill it just with lan ipbackup_server_ipaddress_ Public=xxx.xxx.xxx.xxxbackup_server_ipaddress_private=10.129.16.243# select lan ip first  for transmission speedbackup_server_hostname=${backup_server_ipaddress_private:-$backup _server_ipaddress_public}backup_server_ssh_username=root# backup_server_ssh_port=$ (awk  '/port/ {print $2} '  /etc/ssh/sshd_config) backup_server_ssh_ port=$ (netstat -anop | awk  '/sshd/ && /listen/ {print $4} '  | awk -F  ': '   ' {print $2} ') backup_server_ssh_hostname= $backup _server_ hostnamebackup_path=/data/gitlab_backup_directorybackup_path_time_uniq=$ (date -d  "Yesterday"  + " %y%m%d ") [ -d  $backup _path/$backup _path_time_uniq ] | |  mkdir -p  $backup _path/$backup _path_time_uniq# sudo -u gitlab_ci -h  bundle exec rake backup:create rails_env=production/data/opt/gitlab/bin/gitlab-rake  Gitlab:backup:create > $backup _path/backup_path_time_uniq/$ (date -d  "Yesterday"  + "%Y%m%d "). log 2>&1[ $? -ne 0 ] && echo  "local backup failed! "  && exit 1;echo  "Local  backup successfully!  "backuped_tar_file= ' awk  '/gitlab_backup.tar/ {print $4} '   $backup _path/backup_path_time_uniq/$ (date -d  "Yesterday"  + "%y%m%d"). Log ' [ -f $ gitlab_internal_backup_directory/$backuped _tar_file ] && echo  "Find backuped  tar file successfully!  "ssh [email protected] $backup _server_ssh_hostname [  -d  $backup _path/$backup _path_time_uniq ] | |  mkdir -p  $backup _path/$backup _path_time_uniq[ $? -ne 0 ] &&  echo  "remote backup directory creation failed! "  && exit  1;echo  "remote backup directory creation successfully! " Scp -p$port   $gitlab _internal_backup_directory/$backuped _tar_file [eMail protected] $backup _server_ssh_hostname: $backup _path/$backup _path_time_uniq [ $? -ne  0 ] && echo  "remote backup transmission failed! "   && exit 1;echo  "remote backup transmission successfully! " find   $gitlab _internal_backup_directory -mtime + $save _days -exec rm -rf {}  \; [ $? -ne 0 ] && echo  "Local expired backup remove  skipped!  ";echo " local expired backup remove successfully!  "find   $backup _path -mtime + $save _days -exec rm -rf {} \; [ $? -ne 0 ] && echo  "Local expired tempdir remove  skipped!  ";echo " local expired tempdir remove successfully!  "ssh   [email protected] $backup _SERVER_SSh_hostname find  $backup _path -mtime + $save _days -exec rm -rf {} \ ; [ $? -ne 0 ] && echo  "Remote expired backup remove  skipped!  ";echo " remote expired backup remove successfully!  "#  References# gitlab.org / gitlab community edition / backup restore  https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md# gitlab.org  / gitlab ci / backup restore https://gitlab.com/gitlab-org/gitlab-ci/blob/ Master/doc/raketasks/backup_restore.md

confluence Remote script backup scheme

#!/bin/bash#     10.129.16.242                 10.129.16.243# ----------+-----------------------------+------- #           |                               |#     +-----+-----+                 +------+------+#     |      A     |                 |      B       |#     +-----------+                 +-------------+ #     confluence server             backups clinet## This shell  script will execute on b server# a and b passed ssh  authentication# run with root[ $ (id -u)  -ne 0 ] | |  exit 1# save 30 dayssave_days=10# which directory to backup  tobackup_path=/data/confluence_backup_directory# make backups uniqure and  backup per day# backup_path_time_uniq=$ (date -d  "Yesterday"  + "%Y%m%d%H%M%S") backup_path_time_uniq=$ (date -d  "Yesterday"  + "%y%m%d") confluence_home_directory=/data/var/ Atlassian/application-data/confluence# if you have both wan ip and lan  ip, you can fill it With all, if you have one ip, you can fill it just  with lan ipconfluence_server_ipaddress_public=xxx.xxx.xxx.xxxconfluence_server_ipaddress_ Private=10.129.16.242# select lan ip first for transmission speedconfluence _server_hostname=${confluence_server_ipaddress_private:-$confluence _server_ipaddress_public}confluence_server_ ssh_username=root#confluence_server_ssh_port=$ (awk  '/port/ {print $2} '  /etc/ssh/sshd_ Config) confluence_server_ssh_port=$ (netstat -anop | awk  '/sshd/ && / listen/ {print $4} '  | awk -F  ': '   ' {print $2} ') Confluence_server_ssh_ Hostname= $confluence _server_hostname# which files and directory backup#backup_files= ( Confluence.cfg.xml attachments config index) backup_files= (confluence.cfg.xml attachments  index) backup_files_num=${#backup_files[@]}[ -d  $backup _path/$backup _path_time_uniq ] | |  mkdir -p  $backup _path/$backup _path_time_uniq# do ssh copyfor  ( i  = 0; i <  $backup _files_num; i++ ));  doscp -r -p$ Confluence_server_ssh_port [email protected] $confluence _server_ssh_hostname: $confluence _home_ directory/${backup_files[i]}  $backup _path/$backup _path_time_uniq[ $? -ne 0 ]  && echo  "backup failed! "  && exit 1;echo  "backup  successfully!  "# todo# find postgresql dumpdone# delete old  backupsfind  $backup _path -mtime + $save _days -exec rm -rf {} \;#  references# production backup strategyhttps://confluence.atlassian.com/display/doc/production+ Backup+strategy# configuring backups https://confluence.atlAssian.com/display/doc/configuring+backups#configuringbackups-enablingbackuppathconfiguration# valid  Backup File Date Patterns are based on the Java  simpledateformat classhttp://docs.oracle.com/javase/7/docs/api/java/text/simpledateformat.html# #  perform_backups enable# backupfilename (Sample) backup-2015_08_17# backup file  prefix backup-# backup file date pattern yyyy_mm_dd# backup path  /data/var/atlassian/application-data/confluence/backups# confluence home directory/data/var/ atlassian/application-data/confluence/

--end--

This article is from "Communication, My Favorites" blog, please make sure to keep this source http://dgd2010.blog.51cto.com/1539422/1685340

Gitlab and Confluence Backup solution V0.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.