-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathk-repo-create-sftp.sh
More file actions
executable file
·35 lines (27 loc) · 982 Bytes
/
k-repo-create-sftp.sh
File metadata and controls
executable file
·35 lines (27 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# Can promt to set mandatory password for repository encryption
# set -e
set -uo pipefail
# set -x
script_dir="$( cd "$( dirname "$0" )" && pwd )"
source $script_dir/config
# `config` overwrites:
# repo_main="u281892@u281892.your-storagebox.de:23"
# repository_folder="/home/kopia/json"
repo="$repo_main"
keyfile="$script_dir/keys/id_kopia"
knownhosts="$script_dir/keys/known_hosts"
username=${repo%%@*}
host=$(echo $repo | sed 's/.*@//' | sed 's/:/\t/g' | awk '{print $1}')
port=$(echo $repo | sed 's/.*://')
[[ -n $(grep "$host" "$script_dir/keys/known_hosts") ]] || ssh-keyscan -p $port $host >> "$knownhosts" 2> /dev/null
kopia repository create sftp \
--config-file "$script_dir/repositories/repo-$username@$host.config" \
--cache-directory "$script_dir/cache/" \
--username $username \
--host $host \
--port $port \
--keyfile $keyfile \
--known-hosts $knownhosts \
--path $repository_folder
# kopia repository validate-provider