add bashup::set-existing_backups function

This commit is contained in:
Matthew Saunders Brown 2024-08-15 12:58:40 -07:00
parent 3e60032793
commit 8fc3322505
6 changed files with 14 additions and 10 deletions

View File

@ -8,6 +8,7 @@
source $(dirname $0)/bashup.sh
bashup::set-retention_array
bashup::set-existing_backups
# create backup for today
if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then

View File

@ -92,6 +92,7 @@ if [ ! -z "$backup" ]; then
fi
else
# output list of backups (dates)
bashup::set-existing_backups
for existing_backup in "${existing_backups[@]}"; do
echo $existing_backup
done

View File

@ -52,7 +52,7 @@ while getopts "b:np:h" opt; do
esac
done
bashup::set_existing_backups
bashup::set-existing_backups
# prompt if backup was not set on command line
if [ -z "$backup" ] ; then

View File

@ -52,7 +52,7 @@ while getopts "b:d:nh" opt; do
esac
done
bashup::set_existing_backups
bashup::set-existing_backups
# prompt if backup was not set on command line
if [ -z "$backup" ] ; then

View File

@ -52,7 +52,7 @@ while getopts "b:nz:h" opt; do
esac
done
bashup::set_existing_backups
bashup::set-existing_backups
# prompt if backup was not set on command line
if [ -z "$backup" ] ; then

View File

@ -106,14 +106,16 @@ fi
# get todays date (backup dir name)
today=$(date +%Y%m%d)
# set existing_backups array
existing_backups=($(ls $backup_storage_dir|grep -v lost+found))
# if script is a *-backup-* script remove today from existing backups, if it exists. we do other checks avoid re-doing backups
if [[ "$0" == *"-backup-"* ]];then
if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then
unset 'existing_backups[-1]';
function bashup::set-existing_backups () {
# set existing_backups array
existing_backups=($(ls $backup_storage_dir|grep -v lost+found))
# if script is a *-backup-* script remove today from existing backups, if it exists. we do other checks avoid re-doing backups
if [[ "$0" == *"-backup-"* ]];then
if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then
unset 'existing_backups[-1]';
fi
fi
fi
}
function bashup::set-retention_array () {