Open YesThatAllen opened 1 year ago
The backup script and process has been problematic for a while. Ideally it is not self contained w/in the project folder but is getting backed up to a separate partition or remote storage. But in any case, suggestions here are valid and improvements need to be made. I would welcome any help. 😁
Ideally it is not self contained w/in the project folder
We'll have a more unified experience if the script itself is in the repo
but is getting backed up to a separate partition or remote storage.
Absolutely. I envision a file where users define all sorts of variables.. timezone, backup destination, etc.
pypowerwall.env currently hosts some values including TZ
, is it fair to say that's where we can put things like
BACKUP_DESTINTATION
BACKUP_DAYS_TO_KEEP
(other values as needed)
the nice part about how you laid out that file already is that we can call: pseudocode here:
pypowerwall_repo_home=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pypowerwall_env_file="$pypowerwall_repo_home/pypowerwall.env"
echo "pypowerwall_env_file is $pypowerwall_env_file"
if [[ -f $pypowerwall_env_file ]]; then
source "$pypowerwall_env_file"
else
echo "You must have messed up somewhere."
exit 1
fi
if [[ ! -z "$TZ" ]]; then
echo "ensure TZ is defined in $pypowerwall_env_file"
exit 1
fi
Which will make the values stored there available in scripts like $TZ
Problem
The existing backup script requires users to make their own copies, and as such isn't as easy as it could be, and changes to the process aren't reliably enforceable.
Enhancements
$pypowerwall_repo_home
to find the path to the repo, egpowerwall_repo="${BASH_SOURCE[0]}"
$powerwall_repo
)mkdir -p
to ensure folders existsudo
... invoking sudo within the script as needed is safer than running the whole script as root.Additional context
I'd start with moving the existing
backups/backup.sh.example
to the repo root asbackup.sh
so that it's at the same level as other tooling, and to prevent conflicts with any existing tooling people have made