|
@@ -50,21 +50,93 @@ function upgrade_gogs {
|
50
|
50
|
}
|
51
|
51
|
|
52
|
52
|
function backup_local_gogs {
|
53
|
|
- if grep -q "Gogs domain" $COMPLETION_FILE; then
|
54
|
|
- if [ -d /home/git/gogs-repositories ]; then
|
55
|
|
- GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
|
53
|
+ if ! grep -q "Gogs domain" $COMPLETION_FILE; then
|
|
54
|
+ return
|
|
55
|
+ fi
|
|
56
|
+
|
|
57
|
+ if [ ! -d /home/git/gogs-repositories ]; then
|
|
58
|
+ return
|
|
59
|
+ fi
|
|
60
|
+
|
|
61
|
+ GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
|
62
|
+
|
|
63
|
+ echo $"Backing up gogs"
|
|
64
|
+
|
|
65
|
+ function_check backup_database_to_usb
|
|
66
|
+ backup_database_to_usb gogs
|
56
|
67
|
|
57
|
|
- echo $"Backing up gogs"
|
|
68
|
+ function_check backup_directory_to_usb
|
|
69
|
+ backup_directory_to_usb $GOPATH/src/github.com/gogits/gogs/custom gogs
|
|
70
|
+ backup_directory_to_usb /home/git/gogs-repositories gogsrepos
|
|
71
|
+ backup_directory_to_usb /home/git/.ssh gogsssh
|
58
|
72
|
|
59
|
|
- function_check backup_database_to_usb
|
60
|
|
- backup_database_to_usb gogs
|
|
73
|
+ echo $"Gogs backup complete"
|
|
74
|
+}
|
61
|
75
|
|
62
|
|
- function_check backup_directory_to_usb
|
63
|
|
- backup_directory_to_usb $GOPATH/src/github.com/gogits/gogs/custom gogs
|
64
|
|
- backup_directory_to_usb /home/git/gogs-repositories gogsrepos
|
65
|
|
- backup_directory_to_usb /home/git/.ssh gogsssh
|
|
76
|
+function restore_local_gogs {
|
|
77
|
+ if ! grep -q "Gogs domain" $COMPLETION_FILE; then
|
|
78
|
+ return
|
|
79
|
+ fi
|
|
80
|
+ if [ ! -d /home/git/gogs-repositories ]; then
|
|
81
|
+ return
|
|
82
|
+ fi
|
66
|
83
|
|
67
|
|
- echo $"Gogs backup complete"
|
|
84
|
+ GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
|
|
85
|
+
|
|
86
|
+ export GVM_ROOT=$GVM_HOME
|
|
87
|
+ if [ -d $GVM_ROOT/bin ]; then
|
|
88
|
+ cd $GVM_ROOT/bin
|
|
89
|
+ [[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
|
|
90
|
+ gvm use go${GO_VERSION} --default
|
|
91
|
+ systemctl set-environment GOPATH=$GOPATH
|
|
92
|
+ fi
|
|
93
|
+
|
|
94
|
+ if [ ${#GIT_DOMAIN_NAME} -gt 2 ]; then
|
|
95
|
+ function_check restore_database
|
|
96
|
+ restore_database gogs ${GIT_DOMAIN_NAME}
|
|
97
|
+ temp_restore_dir=/root/tempgogs
|
|
98
|
+ if [ -d $USB_MOUNT/backup/gogs ]; then
|
|
99
|
+ echo $"Restoring Gogs settings"
|
|
100
|
+ if [ ! -d $GOPATH/src/github.com/gogits/gogs/custom ]; then
|
|
101
|
+ mkdir -p $GOPATH/src/github.com/gogits/gogs/custom
|
|
102
|
+ fi
|
|
103
|
+ cp -r ${temp_restore_dir}/$GOPATH/src/github.com/gogits/gogs/custom/* $GOPATH/src/github.com/gogits/gogs/custom
|
|
104
|
+ if [ ! "$?" = "0" ]; then
|
|
105
|
+ function_check set_user_permissions
|
|
106
|
+ set_user_permissions
|
|
107
|
+ function_check backup_unmount_drive
|
|
108
|
+ backup_unmount_drive
|
|
109
|
+ exit 981
|
|
110
|
+ fi
|
|
111
|
+ echo $"Restoring Gogs repos"
|
|
112
|
+ function_check restore_directory_from_usb
|
|
113
|
+ restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
|
|
114
|
+ cp -r ${temp_restore_dir}repos/home/git/gogs-repositories/* /home/git/gogs-repositories/
|
|
115
|
+ if [ ! "$?" = "0" ]; then
|
|
116
|
+ function_check set_user_permissions
|
|
117
|
+ set_user_permissions
|
|
118
|
+ function_check backup_unmount_drive
|
|
119
|
+ backup_unmount_drive
|
|
120
|
+ exit 67574
|
|
121
|
+ fi
|
|
122
|
+ echo $"Restoring Gogs authorized_keys"
|
|
123
|
+ function_check restore_directory_from_usb
|
|
124
|
+ restore_directory_from_usb ${temp_restore_dir}ssh gogsssh
|
|
125
|
+ if [ ! -d /home/git/.ssh ]; then
|
|
126
|
+ mkdir /home/git/.ssh
|
|
127
|
+ fi
|
|
128
|
+ cp -r ${temp_restore_dir}ssh/home/git/.ssh/* /home/git/.ssh/
|
|
129
|
+ if [ ! "$?" = "0" ]; then
|
|
130
|
+ function_check set_user_permissions
|
|
131
|
+ set_user_permissions
|
|
132
|
+ function_check backup_unmount_drive
|
|
133
|
+ backup_unmount_drive
|
|
134
|
+ exit 8463
|
|
135
|
+ fi
|
|
136
|
+ rm -rf ${temp_restore_dir}
|
|
137
|
+ rm -rf ${temp_restore_dir}repos
|
|
138
|
+ rm -rf ${temp_restore_dir}ssh
|
|
139
|
+ chown -R git:git /home/git
|
68
|
140
|
fi
|
69
|
141
|
fi
|
70
|
142
|
}
|
|
@@ -73,6 +145,10 @@ function backup_remote_gogs {
|
73
|
145
|
echo -n ''
|
74
|
146
|
}
|
75
|
147
|
|
|
148
|
+function restore_remote_gogs {
|
|
149
|
+ echo -n ''
|
|
150
|
+}
|
|
151
|
+
|
76
|
152
|
function remove_gogs {
|
77
|
153
|
if ! grep -Fxq "install_gogs" $COMPLETION_FILE; then
|
78
|
154
|
return
|