Skip to content

Commit

Permalink
Backup Script
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Nov 3, 2019
1 parent 69b3262 commit b4158fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
banner_launcher
debug_config
backup
18 changes: 18 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

backup_from="${backup_from:-"${XDG_CONFIG_HOME:-~/.config}/banner_launcher"}"
backup_from_target="$(basename "$backup_from")"
backup_from_real_dir="$(dirname "$(realpath --canonicalize-missing "$backup_from")")"

backup_to="${backup_to:-"backup/$(date -u +"%Y_%m_%d_%H_%M_%S").tar.gz"}"
backup_to_dir="$(dirname "$backup_to")"
backup_to_real_path="$(realpath --canonicalize-missing "$backup_to")"

echo "Backing up $backup_from to $backup_to"

mkdir -p "$backup_to_dir"

pushd "$backup_from_real_dir" > /dev/null
tar czf "${backup_to_real_path}" --absolute-names "${backup_from_target}"
popd > /dev/null

0 comments on commit b4158fd

Please sign in to comment.