Various improvements
This commit is contained in:
parent
40fb8613be
commit
61294c9d2c
@ -602,7 +602,6 @@ s3
|
||||
sources=(.) # just pass validation
|
||||
targets=(.)
|
||||
today="$(date +%d_%b_%Y)"
|
||||
s3cmd_config=~/.s3cfg
|
||||
prepare() {
|
||||
systemctl stop gitea.service
|
||||
sleep 5
|
||||
@ -610,7 +609,7 @@ s3
|
||||
backup() {
|
||||
log -p "Dumping Gitea"
|
||||
su -c "/usr/local/bin/gitea dump -c /etc/gitea/app.ini \
|
||||
-f /home/git/.cache/gitea_dump.zip" - git 2>> "$__log_file"
|
||||
-f /home/git/.cache/gitea_dump.zip" - git 2>> "$log_file"
|
||||
backups+=(/home/git/.cache/gitea_dump.zip)
|
||||
tgt_s3cmd s3://mybucket/backups/gitea-$today
|
||||
}
|
@ -282,7 +282,7 @@ for script in "${__args[@]}"; do
|
||||
done
|
||||
|
||||
echo -e "\nBackup [Done]"
|
||||
log -V "Backup finished successsfully"
|
||||
log -V "Backup finished successfully"
|
||||
|
||||
# Remove PID file
|
||||
rm "$pid_file"
|
||||
|
@ -56,7 +56,7 @@ log() {
|
||||
while read -r line; do
|
||||
if [ -n "$line" ]; then
|
||||
if [ -n "$use_syslog" ]; then
|
||||
logger --id="$$" --tag boring_backup "$line"
|
||||
logger --id="$$" --tag boring_backup -- "$line"
|
||||
else
|
||||
# shellcheck disable=SC2154
|
||||
printf '[%s] %s\n' \
|
||||
@ -172,7 +172,8 @@ compress_file() {
|
||||
#
|
||||
# Usage: compress_file FILE
|
||||
|
||||
local compressed
|
||||
local uncompressed="$1"
|
||||
local compressed=
|
||||
|
||||
# Select compression utility and set filename extension.
|
||||
if [ -n "$compression" ]; then
|
||||
@ -185,18 +186,18 @@ compress_file() {
|
||||
# Compress file
|
||||
if [ -n "$cmpr_cmd" ]; then
|
||||
log -V "Compressing file $1 by ${cmpr_cmd%% *} ..."
|
||||
$cmpr_cmd "$1" 2>> "$log_file"
|
||||
compressed="${1}${cmpr_ext}"
|
||||
$cmpr_cmd "$uncompressed" |& log
|
||||
compressed="${uncompressed}${cmpr_ext}"
|
||||
|
||||
# Remove original file.
|
||||
if [ -f "$compressed" ]; then
|
||||
if [ -f "$1" ]; then
|
||||
if [ -f "$uncompressed" ]; then
|
||||
log "Remove uncompressed file $1"
|
||||
rm -- "$1"
|
||||
rm -- "$uncompressed"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
compressed="$1"
|
||||
compressed="$uncompressed"
|
||||
fi
|
||||
|
||||
echo "$compressed"
|
||||
|
@ -63,7 +63,7 @@ src_mysqldump() {
|
||||
log "Run command: $*"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
"$@" > "$sqldump" |& log
|
||||
"$@" > "$sqldump" 2>> "$log_file"
|
||||
sqldump="$(compress_file "$sqldump")" # Compress file
|
||||
backups+=("$sqldump") # Append path to 'backups' array
|
||||
log "Dump saved as: $sqldump"
|
||||
|
@ -64,7 +64,7 @@ src_pg_dump() {
|
||||
log "Run command: $*"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
"$@" > "$sqldump" |& log
|
||||
"$@" > "$sqldump" 2>> "$log_file"
|
||||
sqldump="$(compress_file "$sqldump")" # Compress file
|
||||
backups+=("$sqldump")
|
||||
log "Dump file: $sqldump"
|
||||
|
@ -59,6 +59,6 @@ tgt_cp() {
|
||||
set -- cp --archive "$backup" "$dst_path"
|
||||
|
||||
log "Run command: $*"
|
||||
"$@" |& log
|
||||
"$@" 2>> "$log_file"
|
||||
done
|
||||
}
|
||||
|
@ -71,5 +71,5 @@ tgt_s3cmd() {
|
||||
# Upload backups
|
||||
# shellcheck disable=SC2154
|
||||
#"$@" 2>> "$log_file"
|
||||
"$@" |& log
|
||||
"$@" 2>> "$log_file"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user