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