add bashup::set-existing_backups function
This commit is contained in:
parent
3e60032793
commit
8fc3322505
|
@ -8,6 +8,7 @@
|
||||||
source $(dirname $0)/bashup.sh
|
source $(dirname $0)/bashup.sh
|
||||||
|
|
||||||
bashup::set-retention_array
|
bashup::set-retention_array
|
||||||
|
bashup::set-existing_backups
|
||||||
|
|
||||||
# create backup for today
|
# create backup for today
|
||||||
if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then
|
if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then
|
||||||
|
|
|
@ -92,6 +92,7 @@ if [ ! -z "$backup" ]; then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# output list of backups (dates)
|
# output list of backups (dates)
|
||||||
|
bashup::set-existing_backups
|
||||||
for existing_backup in "${existing_backups[@]}"; do
|
for existing_backup in "${existing_backups[@]}"; do
|
||||||
echo $existing_backup
|
echo $existing_backup
|
||||||
done
|
done
|
||||||
|
|
|
@ -52,7 +52,7 @@ while getopts "b:np:h" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
bashup::set_existing_backups
|
bashup::set-existing_backups
|
||||||
|
|
||||||
# prompt if backup was not set on command line
|
# prompt if backup was not set on command line
|
||||||
if [ -z "$backup" ] ; then
|
if [ -z "$backup" ] ; then
|
||||||
|
|
|
@ -52,7 +52,7 @@ while getopts "b:d:nh" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
bashup::set_existing_backups
|
bashup::set-existing_backups
|
||||||
|
|
||||||
# prompt if backup was not set on command line
|
# prompt if backup was not set on command line
|
||||||
if [ -z "$backup" ] ; then
|
if [ -z "$backup" ] ; then
|
||||||
|
|
|
@ -52,7 +52,7 @@ while getopts "b:nz:h" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
bashup::set_existing_backups
|
bashup::set-existing_backups
|
||||||
|
|
||||||
# prompt if backup was not set on command line
|
# prompt if backup was not set on command line
|
||||||
if [ -z "$backup" ] ; then
|
if [ -z "$backup" ] ; then
|
||||||
|
|
|
@ -106,14 +106,16 @@ fi
|
||||||
# get todays date (backup dir name)
|
# get todays date (backup dir name)
|
||||||
today=$(date +%Y%m%d)
|
today=$(date +%Y%m%d)
|
||||||
|
|
||||||
# set existing_backups array
|
function bashup::set-existing_backups () {
|
||||||
existing_backups=($(ls $backup_storage_dir|grep -v lost+found))
|
# set existing_backups array
|
||||||
# if script is a *-backup-* script remove today from existing backups, if it exists. we do other checks avoid re-doing backups
|
existing_backups=($(ls $backup_storage_dir|grep -v lost+found))
|
||||||
if [[ "$0" == *"-backup-"* ]];then
|
# if script is a *-backup-* script remove today from existing backups, if it exists. we do other checks avoid re-doing backups
|
||||||
if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then
|
if [[ "$0" == *"-backup-"* ]];then
|
||||||
unset 'existing_backups[-1]';
|
if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then
|
||||||
|
unset 'existing_backups[-1]';
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
function bashup::set-retention_array () {
|
function bashup::set-retention_array () {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user