Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
copy files
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kubernetes Cluster
deploy
copy files
Commits
0dfc9ef6
Commit
0dfc9ef6
authored
5 months ago
by
Andri Joos
Browse files
Options
Downloads
Patches
Plain Diff
use rsync to copy directories
parent
a600a5d5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
copy_directories.sh
+0
-71
0 additions, 71 deletions
copy_directories.sh
copy_directory.sh
+45
-0
45 additions, 0 deletions
copy_directory.sh
with
45 additions
and
71 deletions
copy_directories.sh
deleted
100644 → 0
+
0
−
71
View file @
a600a5d5
source
mount_nfs.sh
MKDIR
=
"mkdir -p"
;
COPY_DIR
=
"cp -rp"
;
mount_nfs
i
=
1
;
# first arg is script
j
=
$#;
while
[
$i
-le
$j
]
# iterate through arguments
do
DESTINATION_DATA_PATH
=
"
$TEST_MOUNT_PATH
/
$1
"
;
SOURCE_DATA_PATH
=
"
$PROD_MOUNT_PATH
/
$1
"
;
if
[
"
$PROD
"
=
"true"
]
then
DESTINATION_DATA_PATH
=
"
$PROD_MOUNT_PATH
/
$1
"
;
SOURCE_DATA_PATH
=
"
$TEST_MOUNT_PATH
/
$1
"
;
fi
echo
"
$i
:
$DESTINATION_DATA_PATH
"
;
if
[
-d
"
$DESTINATION_DATA_PATH
"
]
# directory exists
then
if
[
-z
"
$(
ls
-A
$DESTINATION_DATA_PATH
)
"
]
# is directory empty
then
if
[
-d
"
$SOURCE_DATA_PATH
"
]
# source path exists
then
if
[
"
$COPY_FILES
"
=
"true"
]
then
DESTINATION_DATA_PATH
=
"
$(
dirname
"
$DESTINATION_DATA_PATH
"
)
"
echo
"copying
$SOURCE_DATA_PATH
to
$DESTINATION_DATA_PATH
"
$MKDIR
$DESTINATION_DATA_PATH
;
$COPY_DIR
"
$SOURCE_DATA_PATH
"
$DESTINATION_DATA_PATH
;
echo
"copied source
$SOURCE_DATA_PATH
to
$DESTINATION_DATA_PATH
"
else
echo
"COPY_FILES is false; skipping copy"
fi
else
echo
"cannot copy, source
$SOURCE_DATA_PATH
does not exist; skipping"
;
fi
else
echo
"
$DESTINATION_DATA_PATH
is not empty; skipping copy data."
;
fi
else
if
[
-d
"
$SOURCE_DATA_PATH
"
]
# source path exists
then
if
[
"
$COPY_FILES
"
=
"true"
]
then
DESTINATION_DATA_PATH
=
"
$(
dirname
"
$DESTINATION_DATA_PATH
"
)
"
echo
"copying
$SOURCE_DATA_PATH
to
$DESTINATION_DATA_PATH
"
$MKDIR
$DESTINATION_DATA_PATH
;
$COPY_DIR
"
$SOURCE_DATA_PATH
"
$DESTINATION_DATA_PATH
;
echo
"copied source
$SOURCE_DATA_PATH
to
$DESTINATION_DATA_PATH
"
else
$MKDIR
$DESTINATION_DATA_PATH
echo
"COPY_FILES is false; created empty dir"
fi
else
$MKDIR
$DESTINATION_DATA_PATH
echo
"cannot copy, source
$SOURCE_DATA_PATH
does not exist; empty folder created"
;
fi
fi
i
=
$((
i
+
1
))
;
shift
1
;
done
unmount_nfs
This diff is collapsed.
Click to expand it.
copy_directory.sh
0 → 100644
+
45
−
0
View file @
0dfc9ef6
test_host
=
"testcluster"
prod_host
=
"prodcluster"
path
=
$1
;
test_path
=
"
${
TEST_NFS_PATH
%%+(/)
}
$path
"
prod_path
=
"
${
PROD_NFS_PATH
%%+(/)
}
$path
"
source_host
=
$prod_host
destination_host
=
$test_host
source_path
=
$prod_path
destination_path
=
$test_path
source_ssh_config
=
$PROD_SSH_CONFIG
destination_ssh_config
=
$TEST_SSH_CONFIG
if
[
$PROD
=
"true"
]
then
# source_host=$test_host
# destination=$prod_host
# source_path=$test_path
# destination_path=$prod_path
# source_ssh_config=$TEST_SSH_CONFIG
# destination_ssh_config=$PROD_SSH_CONFIG
echo
"test to prod copy not supported"
exit
1
fi
source
=
"
$source_host
:
$source_path
"
destination
=
"
$destination_host
:
$destination_path
"
destination_host_ip
=
"
$(
grep
'HostName'
${
destination_ssh_config
}
|
awk
'{print $2}'
)
"
destination_username
=
"
$(
grep
'User'
${
destination_ssh_config
}
|
awk
'{print $2}'
)
"
echo
"PROD:
$PROD
"
if
ssh
-F
$source_ssh_config
$source_host
"[ -d
$source_path
]"
then
copy_destination_path
=
$(
dirname
"
$destination_path
"
)
echo
"copying
$path
from
$source_host
to
$destination_host
"
ssh
-A
-F
$source_ssh_config
$source_host
rsync
-avP
$source_path
$destination_username
@
$destination_host_ip
:
$copy_destination_path
else
echo
"
$path
does not exist in
$source_host
, creating empty directory in
$destination_host
"
ssh
-F
$destination_ssh_config
$destination_host
"mkdir -p
$destination_path
"
fi
This diff is collapsed.
Click to expand it.
Preview
0%
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