Skip to content

Commit

Permalink
Error fixing and some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
giuli635 committed Jan 23, 2024
1 parent d04be02 commit dd7613b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
26 changes: 9 additions & 17 deletions sbackup
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def make_backup(args, config):
def tar_run(backup, config):
paths = ast.literal_eval(config[backup]['paths'])
tar = subprocess.run(
["tar", "--ignore-failed-read", "-c", "-I",
["tar", "--ignore-failed-read", "-C", "/", "-c", "-I",
f"zstd -19 -T{args.cores}", "-f",
f"{location()}/{backup}-{date}.tar.zstd", *paths],
check = True,
Expand All @@ -309,7 +309,7 @@ def make_backup(args, config):
)

for backup in args.backups:
error |= execute_if_found(backup, config, tar_run)
error |= not execute_if_found(backup, config, tar_run)

return error

Expand Down Expand Up @@ -348,7 +348,7 @@ def show_info(args, config):
else:
for backup in args.backups:
print("\033[1m" + backup + "\033[0m")
error |= execute_if_found(backup, config, info_function)
error |= not execute_if_found(backup, config, info_function)

return error

Expand All @@ -358,20 +358,12 @@ def rename_backup(args, config):
config[args.new_name] = config[backup]
config.pop(backup)

error = (
execute_if_found(
args.new_name,
config,
lambda backup, config: print(
f'{backup} is already present in the configuration'
)
)
or not execute_if_found(
args.backup,
config,
rename
)
)
error = False
if args.new_name in config.section():
error = True
print(f'{args.backup} is already present in the configuration')

error = error or not execute_if_found(args.backup, config, rename)

return error

Expand Down
12 changes: 7 additions & 5 deletions sbackup-schedule
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

if [[ "$1" == "run" ]]; then
shift 1
export DISPLAY=":0.0"

for backup in "$@"
do
declare error_code
Expand All @@ -14,19 +16,19 @@ if [[ "$1" == "run" ]]; then

error_code=$?
if [[ $error_code == 0 ]]; then
echo "sbackup-shedule run $backup" | at now + "${response[@]}"
echo "sbackup-schedule run $backup" | at -M now + "${response[@]}"
fi
fi

if [[ "$action" == "" || "$error_code" == 0 ]]; then
if [[ "$action" == "" || "$error_code" != 0 ]]; then
response="$(yad --entry --numeric --center --no-escape --sticky \
--entry-label Cores)"

sbackup make --cores "${response:-1}" -- "$backup"
if [[ $? == 0 ]]; then
if [[ "$?" == 0 ]]; then
notify-send -a sbackup -i drive-harddisk "$backup finished"
else
notify-send -a sbackup -i drive-harddisk \
notify-send -a sbackup -i drive-harddisk \
-u critical "An error ocurred while making $backup backup"
fi
fi
Expand All @@ -52,6 +54,6 @@ else
for backup in "$@"
do
run_time="$(sbackup info -a frequency $backup)"
echo "sbackup-shedule run $backup" | at now + "$run_time"
echo "sbackup-shedule run $backup" | at -M now + "$run_time"
done
fi

0 comments on commit dd7613b

Please sign in to comment.