Last active
September 15, 2017 08:12
-
-
Save musaprg/38110f4986a35ce1974a85f786139870 to your computer and use it in GitHub Desktop.
GitLabとKnowledgeの自動バックアップ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NOTICE: This script must be run as root, | |
# and it also need some packages -> sshpass | |
# To install it, run the code below. | |
# `sudo apt-get install sshpass` | |
##### GitLab ##### | |
# Run Backup | |
/opt/gitlab/bin/gitlab-rake gitlab:backup:create | |
# Copy backup files | |
set -- `ls -t /var/opt/gitlab/backups` | |
sshpass -p 'hogefuga' scp -o StrictHostKeyChecking=no /var/opt/gitlab/backups/$1 [email protected]:/home/hoge/backup/git/ | |
##### Knowledge (Without Overwriting) ##### | |
#FNAME=$(date +%s_%Y_%m_%d)_knowledge | |
#cp -r /home/hoge/knowledge /root/$FNAME | |
#sshpass -p 'hogefuga' scp -o StrictHostKeyChecking=no -r /root/$FNAME [email protected]:/home/hoge/backup/knowledge/ | |
#rm -r /root/$FNAME | |
##### Knowledge (with Overwriting) ##### | |
sshpass -p 'hogefuga' scp -o StrictHostKeyChecking=no /home/hoge/knowledge [email protected]:/home/hoge/backup/knowledge/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
こいつを
sudo crontab -e -u root
とかでcronに追加するといい感じになる