Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
comp-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ITS
comp-backup
Commits
5b112f92
Commit
5b112f92
authored
1 month ago
by
efer
Browse files
Options
Downloads
Patches
Plain Diff
install rclone filter function working + misc
parent
a0a9484f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
comp-backup-install-hench.sh
+23
-15
23 additions, 15 deletions
comp-backup-install-hench.sh
with
23 additions
and
15 deletions
comp-backup-install-hench.sh
+
23
−
15
View file @
5b112f92
...
...
@@ -20,7 +20,6 @@ export LC_CTYPE=
SCRIPTNAME
=
"comp-backup"
VERSION
=
11
LOGNAME
=
"backup_logfile"
LOGNAMESHORT
=
"logfile_short.txt"
TARGETNODE
=
"backup.compute.dtu.dk"
SERIAL
=
"/etc/dtuserial"
H
=
$HOME
...
...
@@ -149,7 +148,7 @@ fi
if
[
-x
$BIN_DIR
/
$SCRIPTNAME
]
;
then
ver
=
$(
grep
"version=[0-9]
\+
"
$BIN_DIR
/
$SCRIPTNAME
|
cut
-d
"="
-f
2
)
if
[
$ver
-lt
$VERSION
]
;
then
echo
"New script version
(
$VERSION
)
will be installed"
echo
-e
$Y_
"New script version
"
$_N
"*
$VERSION
*"
$Y_
"
will be installed"
$_N
if
[
$HOST_OS
=
'Linux'
]
;
then
if
[
$SYSTEMD
=
1
]
;
then
systemctl
--user
stop
$SCRIPTNAME
.timer &>/dev/null
...
...
@@ -280,11 +279,12 @@ if [ -d $H/.local/tmp ]; then
tar
-C
$FILE_DIR
/old
-czf
$FILE_DIR
/old/logs.tar.gz logs
rm
-rf
$FILE_DIR
/old/logs
fi
echo
-e
"[cleanup]
i
"
$G_
"OK"
$_N
echo
-e
"[cleanup]"
$G_
"OK"
$_N
#
# Rclone config
#
echo
-e
"
\n
Writing rclone files..."
RCLONE_DIR
=
"
$H
/.config/rclone"
pwg
()
{
openssl rand
-base64
16 | rclone obscure -
...
...
@@ -325,13 +325,15 @@ else
# If $RCLONE_DIR exists but no config
rcloneconf
fi
echo
-e
"[rclone config]"
$G_
"OK"
$_N
#
# Prepare Rclone filter
#
FILTER
=
$FILTER_URL
/filter_
$HOST_OS
.templ
defaultfilter
()
{
if
[[
"curl -s
$FILTER
|grep -q
$SCRIPTNAME
"
]]
;
then
curl
-s
$FILTER
|grep
-q
$SCRIPTNAME
if
[
$?
-eq
0
]
;
then
# Check for default & user filter
if
[
!
-f
$CONF_DIR
/filter.orig
]
;
then
curl
-s
$FILTER
|sed s/user/
$RUSER
/g
>
$CONF_DIR
/filter.orig
...
...
@@ -340,20 +342,24 @@ if [[ "curl -s $FILTER|grep -q $SCRIPTNAME" ]]; then
fi
elif
[
!
-f
$CONF_DIR
/filter
]
;
then
cp
$CONF_DIR
/filter.orig
$CONF_DIR
/filter
fi
else
# Check for updated default filter
if
[[
!
"curl -s
$FILTER
|sed s/user/
$RUSER
/g|diff
$CONF_DIR
/filter.orig -"
]]
;
then
if
[[
"diff
$CONF_DIR
/filter
$CONF_DIR
/filter.orig"
]]
;
then
curl
-s
$FILTER
|sed s/user/
$RUSER
/g|diff
$CONF_DIR
/filter.orig - &>/dev/null
if
[
$?
-ne
0
]
;
then
diff
$CONF_DIR
/filter
$CONF_DIR
/filter.orig &>/dev/null
if
[
$?
-ne
0
]
;
then
curl
-s
$FILTER
|sed s/user/
$RUSER
/g
>
$CONF_DIR
/filter.orig
#cp $CONF_DIR/filter $FILE_DIR/old/filter.$(date +%Y-%m-%d)
cp
$CONF_DIR
/filter.orig
$CONF_DIR
/filter
echo
-e
"[rclone filter]"
$Y_
"Updated filter.orig downloaded"
$_N
else
curl
-s
$FILTER
|sed s/user/
$RUSER
/g
>
$CONF_DIR
/filter.orig
echo
-e
$Y_
"Updated filter.orig downloaded"
$_N
cp
$CONF_DIR
/filter.orig
$CONF_DIR
/filter
fi
else
echo
-e
"[rclone filter]"
$G_
"OK"
$_N
fi
fi
else
echo
-e
$R_
"Cannot download filter template from server..."
$_N
echo
-e
"[rclone filter]"
$R_
"Cannot download filter template from server..."
$_N
exit
1
fi
}
...
...
@@ -368,8 +374,10 @@ defaultfilter
#
echo
-e
"
\n
Writing backup script files..."
# Log vars
LOG
=
$FILE_DIR
/
$LOGNAME
LOGSHORT
=
$LOG
-short
LOGNAMESHORT
=
"logfile_short.txt"
SNAPDIR
=
".zfs/snapshot"
# Rclone command
...
...
@@ -480,7 +488,7 @@ fi
# Log update
echo -e "Serial number:
$SERIALNUMBER
" >
$LOGSHORT
echo -e "
comp-backup
version:
\$
version" >>
$LOGSHORT
echo -e "
$SCRIPTNAME
version:
\$
version" >>
$LOGSHORT
export OS_VER=
$OS_VER
echo -e "OS version:
\$
OS_VER" >>
$LOGSHORT
tail -n 6
$LOG
>>
$LOGSHORT
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment