Skip to content

Commit 9e05133

Browse files
committed
Added basic backblaze b2 support
Issue #41
1 parent afab6f4 commit 9e05133

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

agb_logo.png

18.2 KB
Loading

auto-gitlab-backup.conf.sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ remoteDest="/var/opt/gitlab/backups"
1616
# change to 1 to enable
1717
backupConfigs="0"
1818

19+
## enable backblaze b2 sync
20+
# change to 1 to enable
21+
# and set bucketname
22+
# and change b2keepDays if other than 5 days is desired
23+
b2blaze=0
24+
b2Bucketname=""
25+
b2keepDays="5"
26+
1927
## set $localConfDir
2028
# blank disables conf backups
2129
# you can create /var/opt/gitlab/backups/configBackups --

auto-gitlab-backup.sh

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ usage() {
221221
echo "Usage:"
222222
echo "$0 -h | --help this help page"
223223
echo "$0 -d | --dry-run test rsync operations; no data transmitted."
224-
echo "$0 no options, perform backup and rsync."
224+
echo "$0 no options, perform backup, rsync or b2 operations."
225225
echo ""
226226
}
227227

@@ -239,6 +239,39 @@ areWeRoot() {
239239
fi
240240
}
241241

242+
b2Sync() {
243+
# b2 sync
244+
echo =============================================================
245+
echo -e "Start b2 sync of $gitRakeBackups to bucket $b2Bucketname \n"
246+
247+
if [[ $b2blaze == 0 ]]
248+
then
249+
echo "Backblaze b2 file operations not enabled!"
250+
else
251+
252+
# test for b2 command
253+
if type b2 > /dev/null 2>&1
254+
then
255+
# bucketname set and readable
256+
if [ ! -z $b2Bucketname ]
257+
then
258+
if test -r "$gitRakeBackups" -a -d "$gitRakeBackups"
259+
then
260+
b2 sync --keepDays $b2keepDays --replaceNewer $gitRakeBackups/ b2://$b2Bucketname/
261+
else
262+
echo " gitRakeBackups ($gitRakeBackups) not readable."
263+
fi
264+
else
265+
echo " b2Bucketname not set."
266+
fi
267+
else
268+
echo " b2 command not found!"
269+
fi
270+
271+
fi
272+
echo ""
273+
}
274+
242275
confFileExist() {
243276
# read the conffile
244277
if [ -e $confFile -a -r $confFile ]
@@ -267,10 +300,12 @@ case $1 in
267300
if [[ $remoteModule != "" ]]
268301
then
269302
rsyncDaemon_dryrun
303+
b2Sync
270304
# no Daemon so lets see if we are using a special key
271305
else if [ -e $sshKeyPath -a -r $sshKeyPath ] && [[ $sshKeyPath != "" ]]
272306
then
273307
rsyncKey_dryrun
308+
b2Sync
274309
sshQuotaKey
275310
else if [[ $remoteServer != "" ]]
276311
then
@@ -295,15 +330,18 @@ case $1 in
295330
if [[ $remoteModule != "" ]]
296331
then
297332
rsyncDaemon
333+
b2Sync
298334
# no Daemon so lets see if we are using a special key
299335
else if [ -e $sshKeyPath -a -r $sshKeyPath ] && [[ $sshKeyPath != "" ]]
300336
then
301337
rsyncKey
338+
b2Sync
302339
sshQuotaKey
303340
else if [[ $remoteServer != "" ]]
304341
then
305342
# use the defualt
306343
rsyncUp
344+
b2Sync
307345
sshQuota
308346
fi
309347
fi

0 commit comments

Comments
 (0)