Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
registry-docker
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
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
shore
registry-docker
Commits
9dd7fa96
Commit
9dd7fa96
authored
3 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Restore script.
parent
a5b469f6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#2405
passed
3 years ago
Stage: deploy
Stage: .post
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backup/Dockerfile
+1
-0
1 addition, 0 deletions
backup/Dockerfile
backup/backup
+4
-1
4 additions, 1 deletion
backup/backup
backup/restore
+61
-0
61 additions, 0 deletions
backup/restore
with
66 additions
and
1 deletion
backup/Dockerfile
+
1
−
0
View file @
9dd7fa96
...
...
@@ -3,6 +3,7 @@ FROM docker.io/library/alpine:3.14
RUN
echo
'https://dl-cdn.alpinelinux.org/alpine/edge/testing'
>>
/etc/apk/repositories
&&
\
echo
'https://dl-cdn.alpinelinux.org/alpine/edge/community'
>>
/etc/apk/repositories
&&
\
apk add
--update
--no-cache
\
findutils
\
skopeo
\
reg
\
;
...
...
This diff is collapsed.
Click to expand it.
backup/backup
+
4
−
1
View file @
9dd7fa96
...
...
@@ -17,6 +17,8 @@ then
exit
1
fi
command
-v
skopeo
>
/dev/null
||
{
echo
'skopeo is missing.'
>
&2
;
exit
2
;
}
registry
=
"
$1
"
dest
=
"
$2
"
...
...
@@ -44,6 +46,7 @@ NR>2 {
}
}
END {
exit retruncode
if ( exitcode == 1) print "Backup failed for some images."
exit exitcode
}
'
This diff is collapsed.
Click to expand it.
backup/restore
+
61
−
0
View file @
9dd7fa96
#!/bin/sh
set
-eu
usage
()
{
echo
"
$0
: BACKUP_SOURCE REGISTRY_DOMAIN"
}
if
[
"
${
1
:-}
"
=
-h
]
||
[
"
${
1
:-}
"
=
--help
]
then
usage
exit
0
fi
if
[
"$#"
-ne
2
]
then
usage
exit
1
fi
command
-v
skopeo
>
/dev/null
||
{
echo
'skopeo is missing.'
>
&2
;
exit
2
;
}
src
=
"
$1
"
registry
=
"
$2
"
# There's an assumption here that filenames don't have spaces (or other such
# characters) as the image format prohibits that and I don't want to deal with
# such issues right now.
images
=
"
$(
find
"
$src
"
-maxdepth
1
-mindepth
1
-type
d
-printf
'%f\n'
)
"
if
[
-z
"
$images
"
]
then
echo
'No images found,'
>
&2
exit
3
fi
returncode
=
0
for
image
in
$images
do
tags
=
"
$(
find
"
$src
/
$image
"
-maxdepth
1
-mindepth
1
-type
f
-name
'*.tar'
-printf
'%f\n'
|
sed
's/\.tar$//g'
)
"
if
[
-z
"
$tags
"
]
then
echo
"No tags found for image
$image
, skipping."
>
&2
continue
fi
for
tag
in
$tags
do
echo
"Restoring
$image
:
$tag
"
>
&2
if
skopeo copy
"docker-archive://
$src
/
$image
/
$tag
.tar"
"docker://
$registry
/
$image
:
$tag
"
then
echo
"Restore finished successfully."
>
&2
else
echo
"Restore failed, continuing with other image."
>
&2
returncode
=
1
fi
done
done
if
[
"
$returncode
"
-gt
0
]
then
echo
'Restoration failed for some images.'
fi
exit
"
$returncode
"
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