X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=all_new_2018%2Fborg.sh;h=2c276bf27b090519709fca4054be43c9430a74d4;hb=78e690e37dc3b86b5563697268c07da7baae4ae3;hp=8cf0c441d42f75b8ccab931716ffc651e0358fb9;hpb=635bf647cf1479353c9e1b8423055cdb324a9c27;p=config diff --git a/all_new_2018/borg.sh b/all_new_2018/borg.sh index 8cf0c44..2c276bf 100755 --- a/all_new_2018/borg.sh +++ b/all_new_2018/borg.sh @@ -10,14 +10,17 @@ usage() { echo "store" echo "check" echo "export_keyfiles" + echo "orgpush" + echo "orgpull" false } read_pw() { eval $(ssh-agent) + echo "ssh-add" ssh-add stty -echo - printf "Passphrase: " + printf "Borg passphrase: " read password stty echo printf "\n" @@ -102,6 +105,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