Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SnipeIt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OskarStenberg
SnipeIt
Commits
9257d5e1
Commit
9257d5e1
authored
3 years ago
by
Oskar Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
Updated backup script to patch images and env-files as well
parent
785d7d31
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
backup.sh
+22
-2
22 additions, 2 deletions
backup.sh
with
22 additions
and
2 deletions
backup.sh
+
22
−
2
View file @
9257d5e1
...
...
@@ -135,6 +135,11 @@ if ! [ -d "$destinationDir/$lastBackup/patches" ]; then
mkdir
"
$destinationDir
/
$lastBackup
/patches"
fi
#If there are no current file folders, create a folder for them
if
!
[
-d
"
$destinationDir
/
$lastBackup
/patches/files"
]
;
then
mkdir
"
$destinationDir
/
$lastBackup
/patches/files"
fi
#Check and copy all files (images, .env) that are either new or changed.
cd
new
files
=
$(
find
".
$snipeitDirectory
"
-type
f
)
...
...
@@ -143,11 +148,26 @@ echo "$files"
echo
"Trying to copy:"
while
IFS
=
read
-r
file
;
do
if
!
[
-f
"
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
]
||
[
"
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
-ot
"
$file
"
]
;
then
if
!
[
-f
"
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
]
;
then
cp
-u
--parents
"
$file
"
"
$destinationDir
/
$lastBackup
/"
echo
"Copied
$file
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
else
echo
"File already exists:
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
#Om filen redan finns, kolla om den finns i en nyare version på disken. Om den är nyare, kolla om den redan patchats.
if
[
"
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
-ot
"
$file
"
]
;
then
lastFilePatch
=
$(
ls
-lt
"
$destinationDir
/
$lastBackup
/patches/files"
|
head
-2
|
tail
-1
|
awk
'{print $9}'
)
if
[
"
$destinationDir
/
$lastBackup
/patches/files/
$lastFilePatch
/
$(
echo
$file
|
cut
-c
3-
)
"
-ot
"
$file
"
]
;
then
#If there are no current file folders for this backup, create a folder for them
if
!
[
-d
"
$destinationDir
/
$lastBackup
/patches/files/
$now
"
]
;
then
mkdir
"
$destinationDir
/
$lastBackup
/patches/files/
$now
"
fi
cp
--parents
"
$file
"
"
$destinationDir
/
$lastBackup
/patches/files/
$now
/"
echo
"Copied
$file
$destinationDir
/
$lastBackup
/patches/files/
$now
/
$(
echo
$file
|
cut
-c
3-
)
"
else
echo
"File is already patched:
$destinationDir
/
$lastBackup
/patches/files/
$lastFilePatch
/
$(
echo
$file
|
cut
-c
3-
)
"
fi
else
echo
"File already exists
$destinationDir
/
$lastBackup
/
$(
echo
$file
|
cut
-c
3-
)
"
fi
fi
done
<<<
"
$files
"
...
...
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