One-button backup Gitolite server shell script _linux shell

Source: Internet
Author: User
Tags git clone

Once run, the warehouse on the Gitolite server can be backed up to the local. The first run creates a local mirror of the remote warehouse, which updates the local mirror each time it runs.

This program only supports SSH mode

Other GIT servers do not seem to return the repo list when SSH git@xxx, so they can only be backed up manually.

#!/bin/sh server=serv_addr 
root_dir= ' pwd ' 
 echo ' Whill back in dir: ${root_dir} '
 ssh ' git@${server} ' | awk ' { Print $1$2,$3} ' | grep "^RW" | awk ' {print $} ' | While the read line do
  echo ""
  echo "-------------------------------------"
  if [! -D "${root_dir}/${line}.git"]; Then
    echo "Repo not init", init it ... "
        mkdir-p" ${root_dir}/${line}.git "
        CD" ${root_dir}/${line}.gi T "
        CD.. 
    git clone--mirror "Git@${server}:${line}.git"
  else
    echo repo already init on local, update it ... "
    CD" ${ Root_dir}/${line}.git "
    git remote update 
    git gc 
  fi done
Related Article

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.