X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=sidebyside;f=all_new_2018%2Fborg.sh;h=18321b15fa949256cc3cd13077e6002ef73cee52;hb=17489120d557d9af614693ff6ee60a904ede4629;hp=522285a481c35556aeac0c37377bcbe1ba0c00e4;hpb=a7fd0ec1f6d465ec9e1460e7430fcb5ccc1d3257;p=config
diff --git a/all_new_2018/borg.sh b/all_new_2018/borg.sh
index 522285a..18321b1 100755
--- a/all_new_2018/borg.sh
+++ b/all_new_2018/borg.sh
@@ -10,16 +10,27 @@ usage() {
echo "store"
echo "check"
echo "export_keyfiles"
+ echo "orgpush"
+ echo "orgpull"
false
}
read_pw() {
- stty -echo
- printf "Passphrase: "
- read password
- stty echo
- printf "\n"
- export BORG_PASSPHRASE="${password}"
+ if [ "${#SSH_AGENT_PID}" -eq 0 ]; then
+ eval $(ssh-agent)
+ echo "ssh-add"
+ stty -echo
+ ssh-add
+ stty echo
+ fi
+ if [ "${#BORG_PASSPHRASE}" -eq 0 ]; then
+ stty -echo
+ printf "Borg passphrase: "
+ read password
+ stty echo
+ printf "\n"
+ export BORG_PASSPHRASE="${password}"
+ fi
}
if [ ! -f "${config_file}" ]; then
@@ -100,6 +111,35 @@ elif [ "${first_arg}" = "export_keyfiles" ]; then
mv "${tar_target}" "${cur_dir}"
cd
rm -rf "${tmp_dir}"
+elif [ "${first_arg}" = "orgpush" ]; then
+ archive_name="orgdir"
+ to_backup=~/org
+ read_pw
+ cat "${config_file}" | while read line; do
+ first_char=$(echo "${line}" | cut -c1)
+ if [ "${first_char}" = "#" ]; then
+ continue
+ fi
+ repo="${line}:${standard_repo}"
+ archive="${repo}::${archive_name}-{utcnow:%Y-%m-%dT%H:%M}"
+ echo "Creating archive: ${archive}"
+ borg create --verbose --list "${archive}" "${to_backup}" --exclude ~/org/.git
+ done
+elif [ "${first_arg}" = "orgpull" ]; then
+ archive_name="orgdir"
+ read_pw
+ cd /
+ cat "${config_file}" | while read line; do
+ first_char=$(echo "${line}" | cut -c1)
+ if [ "${first_char}" = "#" ]; then
+ continue
+ fi
+ repo="${line}:${standard_repo}"
+ archive=$(borg list "${repo}" | grep "${orgdir}" | tail -1 | cut -f1 -d' ')
+ echo "Pulling archive: ${archive}"
+ borg extract --verbose "${repo}::${archive}"
+ break
+ done
else
usage
fi