Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
wiki:backup_date [2011/05/26 13:39] – [Backup with Date and Time] Guy | wiki:backup_date [2011/05/26 16:50] (current) – [Backup with Date and Time] Guy | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Backup with Date and Time ====== | ====== Backup with Date and Time ====== | ||
- | Following is a guide on how to save a backup or encrypted backup with the date and time. You need to be using backup or encrypted backup. After a predetermined number of backups are created | + | Following is a guide on how to save a backup or encrypted backup with the date and time. You need to be using backup or encrypted backup. After a predetermined number of backups are created (the default is 5), each time a new backup is created, the oldest is deleted. |
The date and time is in the order year, month, day, then hours, minutes and seconds. This keeps the backup files in order. | The date and time is in the order year, month, day, then hours, minutes and seconds. This keeps the backup files in order. | ||
Line 9: | Line 9: | ||
< | < | ||
- | # This saves a copy of mydata.tgz | + | # This saves a copy of backup |
PART=$(cat / | PART=$(cat / | ||
+ | MYDAT=$(cat / | ||
DATE=$(date +" | DATE=$(date +" | ||
- | DATABACK=Data-$DATE.tgz | + | DATABACK=$MYDAT-$DATE.tgz |
- | CRYPTBACK=Data-$DATE.tgz.bfe | + | CRYPTBACK=$MYDAT-$DATE.tgz.bfe |
cd /mnt/$PART | cd /mnt/$PART | ||
- | cp mydata.tgz $DATABACK | + | cp $MYDAT.tgz $DATABACK |
- | cp mydata.tgz.bfe $CRYPTBACK | + | cp $MYDAT.tgz.bfe $CRYPTBACK |
# This deletes the oldest if there are more than the number you select (the default is 5). | # This deletes the oldest if there are more than the number you select (the default is 5). | ||
- | NUMBACK=$(ls | + | NUMBACK=$(ls |
while [ $NUMBACK -gt 5 ] # Change 5 to the number of backups you want to keep. | while [ $NUMBACK -gt 5 ] # Change 5 to the number of backups you want to keep. | ||
do | do | ||
- | ls -1t /mnt/$PART/Data-2*tg* | tail -1 | xargs /bin/rm -f | + | ls -1t $MYDAT-2*tg* | tail -1 | xargs /bin/rm -f |
- | NUMBACK=$(ls | + | NUMBACK=$(ls |
done | done | ||
</ | </ |