mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix deletion of wrong backup directory on the backup server with alpine system
This commit is contained in:
parent
72978889ef
commit
ae41243324
@ -22,7 +22,8 @@ KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeco
|
|||||||
BACKUP_DATE=$(date "+%F_%H-%M-%S")
|
BACKUP_DATE=$(date "+%F_%H-%M-%S")
|
||||||
BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/backup/${BACKUP_DATE}}
|
BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/backup/${BACKUP_DATE}}
|
||||||
|
|
||||||
# create backup fodler
|
printf "Backup folder name: %s\n" $BACKUP_DATE
|
||||||
|
# create backup folder
|
||||||
mkdir -p ${BACKUP_FOLDER}
|
mkdir -p ${BACKUP_FOLDER}
|
||||||
|
|
||||||
# cluster maintenance mode on && Neo4j maintenance mode on
|
# cluster maintenance mode on && Neo4j maintenance mode on
|
||||||
|
|||||||
@ -81,15 +81,16 @@ do
|
|||||||
cd $path
|
cd $path
|
||||||
|
|
||||||
printf "In\n '$path'\n remove:\n"
|
printf "In\n '$path'\n remove:\n"
|
||||||
# TODO: replace 'ls' by 'find . -type d -maxdepth 1'? description: https://unix.stackexchange.com/questions/28939/how-to-delete-the-oldest-directory-in-a-given-directory
|
|
||||||
while [ `ls -1 | wc -l` -gt $keep ]; do
|
while [ `ls -1 | wc -l` -gt $keep ]; do
|
||||||
oldest=`ls -c1 | head -1`
|
# TODO: because 'ls' is not always relyable maybe replace 'ls' by 'find . -type d -maxdepth 1'? description: https://unix.stackexchange.com/questions/28939/how-to-delete-the-oldest-directory-in-a-given-directory
|
||||||
echo " $oldest"
|
# I tested this, but 'find' this is crutial, because of shell compatibilities
|
||||||
|
oldest=`ls -c1 | sort -n | head -1`
|
||||||
|
printf " %s\n" $oldest
|
||||||
rm -rf $oldest
|
rm -rf $oldest
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "Keep the last %d backups:\n" $BACKUP_SAVED_BACKUPS_NUMBER
|
printf "Keep the last %d backups:\n" $BACKUP_SAVED_BACKUPS_NUMBER
|
||||||
ls
|
ls -c1 | sort -n | awk '{print " " $0}'
|
||||||
|
|
||||||
cd $SCRIPT_DIR
|
cd $SCRIPT_DIR
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user