aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-06-07 18:04:38 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-06-07 18:04:38 +0300
commit9ad68d7d18b5e970a556e6ea92284dd14463ca49 (patch)
tree219a408368e7f4fabc79ce76f4a29218645151d9
parentbugfix (diff)
downloadlinux-home-9ad68d7d18b5e970a556e6ea92284dd14463ca49.tar.gz
linux-home-9ad68d7d18b5e970a556e6ea92284dd14463ca49.zip
backup_repo: refactoring
Diffstat (limited to '')
-rw-r--r--.bashrc24
1 files changed, 12 insertions, 12 deletions
diff --git a/.bashrc b/.bashrc
index cf2d13a..50c6132 100644
--- a/.bashrc
+++ b/.bashrc
@@ -274,32 +274,32 @@ doslint_webapi() (
backup_repo() (
set -o errexit
+ local repo_dir="$( realpath . )"
+ local repo_name="$( basename "$repo_dir" )"
+ local backup_dir="$repo_dir"
+
if [ $# -eq 1 ]; then
- local repo_dir_path="$1"
- local backup_dir_path="$( realpath . )"
- elif [ $# -eq 2 ]; then
- local repo_dir_path="$1"
- local backup_dir_path="$2"
- else
- echo "Usage: $FUNCNAME REPO_DIR_PATH [BACKUP_DIR_PATH]" >&2
+ local backup_dir="$1"
+ elif [ $# -gt 1 ]; then
+ echo "Usage: $FUNCNAME [BACKUP_DIR]" >&2
exit 1
fi
- local zip_name="$( basename "$( realpath "$repo_dir_path" )" )_$( date -u +'%Y%m%dT%H%M%S' ).zip"
+ local zip_name="${repo_name}_$( date -u +'%Y%m%dT%H%M%S' ).zip"
git archive \
--format=zip -9 \
- --output="$backup_dir_path/$zip_name" \
- --remote="$repo_dir_path" \
+ --output="$backup_dir/$zip_name" \
+ --remote="$repo_dir" \
HEAD
)
backup_repo_dropbox() {
- backup_repo "$@" "$USERPROFILE/Dropbox/backups"
+ backup_repo "$USERPROFILE/Dropbox/backups"
}
backup_repo_netwrix() {
- backup_repo "$@" '//spbfs02/P/Personal/Egor Tensin'
+ backup_repo '//spbfs02/P/Personal/Egor Tensin'
}
checksums_path='sha1sums.txt'