blob: dc51b40fa20eeb57df369e9e33df178f759f976e (
plain) (
blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
alias list_repo_files='git ls-files -z'
list_repo_dirs() (
set -o errexit
{ printf '.\0' ; list_repo_files ; } \
| xargs -0 dirname -z \
| sort -z \
| uniq -z \
| tail -z -n +2
)
tighten_repo_security() (
set -o errexit
list_repo_files | xargs -0 chmod 0600
list_repo_dirs | xargs -0 chmod 0700
chmod 0700 .git
)
backup_repo() (
set -o errexit
local repo_dir="$( realpath . )"
local repo_name="$( basename "$repo_dir" )"
local backup_dir="$repo_dir"
if [ $# -eq 1 ]; then
backup_dir="$1"
elif [ $# -gt 1 ]; then
echo "$FUNCNAME: usage: $FUNCNAME [BACKUP_DIR]" >&2
exit 1
fi
local zip_name="${repo_name}_$( date -u +'%Y%m%dT%H%M%S' ).zip"
git archive \
--format=zip -9 \
--output="$backup_dir/$zip_name" \
--remote="$repo_dir" \
HEAD
)
backup_repo_dropbox() {
backup_repo "$USERPROFILE/Dropbox/backups"
}
backup_repo_nwx() {
backup_repo '//spbfs02/P/Personal/Egor Tensin'
}
|