Skip to content

Commit

Permalink
bash: deleting old backup files
Browse files Browse the repository at this point in the history
  • Loading branch information
witek committed Feb 3, 2014
1 parent c1b9ad0 commit 4057199
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
5 changes: 3 additions & 2 deletions install-package.bsh
@@ -1,2 +1,3 @@
rm -rf /opt/ilarkesto
tar -xvjf build/ilarkesto.tbz -C /opt
sudo rm -rf /opt/ilarkesto
sudo tar -xvjf build/ilarkesto.tbz -C /opt

Empty file modified src/main/bash/backuprscp.bsh 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/main/bash/backuptar.bsh
Expand Up @@ -25,4 +25,4 @@ tar -cjpf ${DESTINATION_FILE} $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${
if [ $? != 0 ]; then exit 1; fi

echo "Deleting backups older then $CLEANOLDERTHENMINUTES minutes"
find "${DESTINATION_DIR}" -name "bak_${BACKUP_NAME}_*.tbz" -mmin +$CLEANOLDERTHENMINUTES -exec rm -vf {} \;
/opt/ilarkesto/bin/deleteoldfilesexceptone $DESTINATION_DIR "bak_${BACKUP_NAME}_*.tbz" $CLEANOLDERTHENMINUTES
5 changes: 3 additions & 2 deletions src/main/bash/deleteoldbackupfiles.bsh 100644 → 100755
Expand Up @@ -13,5 +13,6 @@ fi
DST=$1
CLEANOLDERTHENMINUTES=$2

find "${DST}" -name "*_20*.tbz" -mmin +$CLEANOLDERTHENMINUTES -exec rm -vf {} \;
find "${DST}" -name "*-data_20*.zip" -mmin +$CLEANOLDERTHENMINUTES -exec rm -vf {} \;

/opt/ilarkesto/bin/deleteoldfilesexceptone $DST "*_20*.tbz" $CLEANOLDERTHENMINUTES
/opt/ilarkesto/bin/deleteoldfilesexceptone $DST "*-data_20*.zip" $CLEANOLDERTHENMINUTES
21 changes: 21 additions & 0 deletions src/main/bash/deleteoldfilesexceptone.bsh
@@ -0,0 +1,21 @@
#!/bin/bash
#
# Deletes old files except one.
#

if [[ $# -lt 3 ]]
then
echo " "
echo "$0: Illegal arguments."
echo " "
echo "Syntax:"
echo "$0 path filename-pattern age-in-minutes"
exit 1
fi

SEARCHPATH=$1
PATTERN=$2
AGE=$3

echo "Deleting files older then $AGE minutes: $SEARCHPATH$PATTERN"
find $SEARCHPATH -name "$PATTERN" -mmin "+$AGE" -type f -printf '%T@ %p\n' | sort -k 1nr | tail -n +2 | cut -d ' ' -f 2 | xargs rm -vf {}
Empty file modified src/main/bash/fetchbackupfiles.bsh 100644 → 100755
Empty file.
Empty file modified src/main/bash/fetchbackuprscp.bsh 100644 → 100755
Empty file.

0 comments on commit 4057199

Please sign in to comment.