diff --git a/.gitignore b/.gitignore
index b04da10..9f7e9ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
*.txt
dist/
-src/backups/
-src/clean
+debian/
NOTE.todo
diff --git a/CHANGELOG b/CHANGELOG
index 5b4f13c..b7aa4f4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+boring_backup (0.1.0) testing; urgency=medium
+
CHANGELOG
All notable changes to this project will be documented in this file.
@@ -6,3 +8,5 @@ CHANGELOG
0.1.0
Initial release.
+
+-- ge Sun, 09 Oct 2022 02:17:10 +0300
diff --git a/Makefile b/Makefile
index 7252f1f..c2839e1 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ BUILD_DIR := ./dist
.PHONY: help tests manpages install uninstall fixpath
-all: manpages
+all: help
help:
@echo 'Usage: make TARGET'
@@ -55,7 +55,7 @@ html: manpages
> $(BUILD_DIR)/share/doc/boring_backup/boring_backup.1.html 2>/dev/null
rm -v grohtml-*.png
-install: manpages
+install: html
@echo prefix: $$prefix
install -Dm755 $(SRC_DIR)/boring_backup $$prefix/bin/boring_backup
install -Dm644 $(SRC_DIR)/lib/lib.sh $$prefix/share/boring_backup/lib.sh
@@ -71,7 +71,11 @@ install: manpages
sed -e "s%LIBRARY=\"\$${LIBRARY:-.\/lib}\"%LIBRARY=\"\$${LIBRARY:-$$prefix\/share\/boring_backup}\"%" \
-i $$prefix/share/boring_backup/lib.sh \
-i $$prefix/bin/boring_backup
+ sed -e "s%log_file=\"\$${log_file:-.\/log.txt}\"%log_file=\"\$${log_file:-\/var\/log\/boring_backup.log}\"%g" \
+ -i $$prefix/bin/boring_backup
+ install -Dm664 $(SRC_DIR)/completion $$prefix/share/bash-completion/completions/boring_backup
install -Dm664 $(BUILD_DIR)/share/man/ru/man1/boring_backup.1.gz $$prefix/share/man/ru/man1/boring_backup.1.gz
+ install -Dm644 $(BUILD_DIR)/share/doc/boring_backup/boring_backup.1.html $$prefix/share/doc/boring_backup/boring_backup.1.html
uninstall:
@echo prefix: $$prefix
@@ -88,11 +92,24 @@ uninstall:
rm $$prefix/share/boring_backup/handlers/targets/s3cmd.sh
rm -rv $$prefix/share/boring_backup
rm $$prefix/share/man/ru/man1/boring_backup.1.gz
+ rm $$prefix/share/doc/boring_backup/boring_backup.1.html
+ rm $$prefix/share/bash-completion/completions/boring_backup
fixpath:
# Set boring_backup library path
@echo prefix: $$prefix
@echo path: $$path
- sed -e "s%LIBRARY=\"\$${LIBRARY:-.\/lib}\"%LIBRARY=\"\$${LIBRARY:-$$path}\"%" \
+ sed -e "s%LIBRARY=\"\$${LIBRARY:-$$prefix\/share\/boring_backup}\"%LIBRARY=\"\$${LIBRARY:-$$path}\"%" \
-i $$prefix/share/boring_backup/lib.sh \
-i $$prefix/bin/boring_backup
+
+deb:
+ test -d $(BUILD_DIR) && rm -rf $(BUILD_DIR) || true
+ make prefix=$(BUILD_DIR)/usr install
+ make prefix=$(BUILD_DIR)/usr path=/usr/share/boring_backup fixpath
+ install -Dm644 control $(BUILD_DIR)/DEBIAN/control
+ install -Dm644 copyright $(BUILD_DIR)/DEBIAN/copyright
+ install -Dm644 CHANGELOG $(BUILD_DIR)/DEBIAN/changelog
+ rm -rfv $(BUILD_DIR)/share
+ mkdir -p debian
+ version=$$(src/boring_backup -V) && dpkg-deb --build $(BUILD_DIR) debian/boring-backup_$$version.deb
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..c2bbfdc
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,25 @@
+pkgname=boring-backup
+pkgver=0.1.0
+pkgrel=1
+pkgdesc="Files and databases backup"
+arch=(any)
+url=https://git.nxhs.cloud/ge/boring_backup
+license=(GPL3)
+depends=(bash coreutils)
+makedepends=(git make )
+provides=('boring_backup')
+conflicts=('boring_backup')
+source=('git+https://git.nxhs.cloud/ge/boring_backup')
+sha256sums=(SKIP)
+build() {
+ cd "$srcdir/$pkgname"
+ make prefix=dist/usr install
+ make prefix=dist/usr path=/usr/share/boring_backup fixpath
+}
+package() {
+ install -Dm755 dist/usr/bin/boring_backup $pkgdir/usr/bin/boring_backup
+ install -Dm644 dist/usr/share/man/ru/man1/boring_backup.1.gz $pkgdir/usr/share/man/ru/man1/boring_backup.1.gz
+ install -Dm644 dist/usr/share/bash-completion/completions/boring_backup $pkgdir/usr/share/bash-completion/completions/boring_backup
+ install -Dm644 dist/usr/share/doc/boring_backup/boring_backup.1.html $pkgdir/usr/share/doc/boring_backup/boring_backup.1.html
+ install -Dm644 dist/usr/share/boring_backup/* $pkgdir/usr/share/boring_backup
+}
diff --git a/control b/control
new file mode 100644
index 0000000..f5d0219
--- /dev/null
+++ b/control
@@ -0,0 +1,9 @@
+Package: boring-backup
+Version: 0.1.0
+Section: admin
+Priority: optional
+Maintainer: ge
+Homepage: https://nixhacks.net/boring_backup/
+Architecture: all
+Depends: bash, coreutils
+Description: Backup files and databases.
diff --git a/copyright b/copyright
new file mode 100644
index 0000000..bad8fc8
--- /dev/null
+++ b/copyright
@@ -0,0 +1,38 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: boring-backup
+Upstream-Contact: https://nixhacks.net/boring_backup
+Source: https://nixhacks.net/boring_backup
+
+Files: *
+Copyright: 2022 ge
+License: GPL-3.0+
+
+Files: debian/*
+Copyright: 2022 ge
+License: GPL-3.0+
+
+License: GPL-3.0+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
+# Please avoid picking licenses with terms that are more restrictive than the
+# packaged work, as it may make Debian's contributions unacceptable upstream.
+#
+# If you need, there are some extra license texts available in two places:
+# /usr/share/debhelper/dh_make/licenses/
+# /usr/share/common-licenses/
diff --git a/docs/manpages/boring_backup.ru.1.rst b/docs/manpages/boring_backup.ru.1.rst
index 25e4152..c88debd 100644
--- a/docs/manpages/boring_backup.ru.1.rst
+++ b/docs/manpages/boring_backup.ru.1.rst
@@ -131,11 +131,11 @@ postgres
См. также ``src_pg_dump``
-sqlite [НЕ РЕАЛИЗОВАН]
- Схема для баз данных SQLite. Мало отличается от `file`, добавлена для
+sqlite
+ Схема для баз данных SQLite. То же самое что и `file`, добавлена для
наглядного обозначения, что ресурсом является БД SQLite, а не иной файл.
- См. также ``src_sqlite``
+ См. также ``src_tar``
s3
Схема Simple Storage Service (S3). Пример использования::
@@ -247,12 +247,25 @@ s3
tzst zstd .zst .tzst
==================== ========== =================== =====================
+``log_file``
+ | Тип: строка
+ | Умолчание: /var/log/boring_backup.log
+
+ Лог файл.
+
``log_date_format``
| Тип: строка
| Умолчание: %d/%b/%Y:%H:%M:%S %z
Формат даты в логе. См. ``date``. См. **КОНФИГУРИРОВАНИЕ**.
+``make_target_dir``
+ | Тип: булев
+ | Умолчение: нет
+
+ Эта переменная используется как флаг разрешающий создание директорий из
+ `targets` с помощью **mkdir -p**.
+
``name``
| Тип: строка
| Умолчание: нет
@@ -419,7 +432,7 @@ s3
Функция записывает сообщения в лог-файл. Лог-файл может быть задан через
опцию **--log-file**, имя этого файла будет сохранено в переменную
- $__log_file. **log** перед записью в файл удаляет из текста
+ $log_file. **log** перед записью в файл удаляет из текста
escape-последовательности ANSI.
Формат лога '[%s] %s\\n', где первое вхождение %s заменяется на дату, а
@@ -574,7 +587,6 @@ s3
удалением локальных бэкапов после загрузки::
compression=xz
- s3cmd_config=~/.s3cfg
sources=(
/var/www/www-data/example.com
mysql://example_user:Smk3mVH2@localhost/example_db
@@ -586,7 +598,7 @@ s3
finalise() {
log -p "\tClean up local backups"
log -p "\tFiles to delete: ${backups[@]}"
- rm -- "${backups[@]}"
+ rm -rfv -- "${backups[@]}"
log -p "\tLocal backups deleted"
}
diff --git a/src/completely.yaml b/src/completely.yaml
new file mode 100644
index 0000000..bc4442a
--- /dev/null
+++ b/src/completely.yaml
@@ -0,0 +1,11 @@
+# See https://github.com/DannyBen/completely
+
+boring_backup:
+ - --help
+ - --version
+ - --verbose
+ - --config
+ - --log-file
+ - --pid-file
+ - --use-syslog
+ -
diff --git a/src/completion b/src/completion
new file mode 100644
index 0000000..123e5e8
--- /dev/null
+++ b/src/completion
@@ -0,0 +1,39 @@
+# boring_backup completion -*- shell-script -*-
+
+# This bash completions script was generated by
+# completely (https://github.com/dannyben/completely)
+# Modifying it manually is not recommended
+
+_boring_backup_completions_filter() {
+ local words="$1"
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ local result=()
+
+ if [[ "${cur:0:1}" == "-" ]]; then
+ echo "$words"
+
+ else
+ for word in $words; do
+ [[ "${word:0:1}" != "-" ]] && result+=("$word")
+ done
+
+ echo "${result[*]}"
+
+ fi
+}
+
+_boring_backup_completions() {
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
+ local compline="${compwords[*]}"
+
+ case "$compline" in
+ *)
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "$(_boring_backup_completions_filter "--help --version --verbose --config --log-file --pid-file --use-syslog")" -- "$cur" )
+ ;;
+
+ esac
+} &&
+complete -F _boring_backup_completions boring_backup
+
+# ex: filetype=sh
diff --git a/src/lib/backup.sh b/src/lib/backup.sh
index dc52243..7e62ced 100644
--- a/src/lib/backup.sh
+++ b/src/lib/backup.sh
@@ -35,7 +35,7 @@ process_source() {
# ^^^ hide password from output ^^^
case "$scheme" in
- file) handler='src_tar';;
+ file|sqlite) handler='src_tar';;
mysql|mariadb) handler='src_mysqldump';;
postgres) handler='src_pg_dump';;
sqlite) handler='src_sqlite';;
diff --git a/src/lib/handlers/sources/tar.sh b/src/lib/handlers/sources/tar.sh
index 9d78942..f9887dc 100644
--- a/src/lib/handlers/sources/tar.sh
+++ b/src/lib/handlers/sources/tar.sh
@@ -36,7 +36,7 @@ src_tar() {
parse_uri "$uri"
# shellcheck disable=SC2154
- if [[ "$scheme" != 'file' ]]; then
+ if [[ ! "$scheme" =~ ^(file|sqlite)$ ]]; then
log -p "Error: Wrong URI scheme: $scheme" >&2; exit 1
fi