Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:backup_date [2011/05/24 03:53] – [Backup with Date and Time] Guywiki: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 backups with the date and time. When it gets to 5, or the number you select, each time a new backup is created, the oldest one is deleted.+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 7: Line 7:
 Open a text editor, and paste the following. Open a text editor, and paste the following.
  
-<code># This saves a copy of mydata.tgz with the date and time.+<code>#!/bin/sh
  
-#!/bin/sh +This saves a copy of backup or encrypted backup with the date and time. 
-PART=sda1  # If not sda1, change this to the correct partition.+ 
 +PART=$(cat /opt/.backup_device) 
 +MYDAT=$(cat /etc/sysconfig/mydata)
 DATE=$(date +"%Y.%m.%d-%H.%M.%S") DATE=$(date +"%Y.%m.%d-%H.%M.%S")
-DATABACK=Data-$DATE.tgz +DATABACK=$MYDAT-$DATE.tgz 
-cd /mnt/$PART/tce/ +CRYPTBACK=$MYDAT-$DATE.tgz.bfe 
-cp mydata.tgz $DATABACK+cd /mnt/$PART 
 +cp $MYDAT.tgz $DATABACK 
 +cp $MYDAT.tgz.bfe $CRYPTBACK
  
-# This deletes the oldest if there are more than 5 (or the number you select).+# This deletes the oldest if there are more than the number you select (the default is 5).
  
-NUMBACK=$(ls Data-* | wc -l)+NUMBACK=$(ls "$MYDAT"-2* | wc -l)
 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/tce/Data-*tgz | tail -1 | xargs /bin/rm -f +ls -1t $MYDAT-2*tg* | tail -1 | xargs /bin/rm -f 
-NUMBACK=$(ls Data-* | wc -l)+NUMBACK=$(ls "$MYDAT"-2* | wc -l)
 done done
 </code> </code>
  
-If you are not using sda1, change it to the correct partition. +Save this file as backdate.sh in /opt.
- +
-Save this as backdate.sh in /opt.+
  
 Open the terminal and type Open the terminal and type
Line 37: Line 39:
  
 <code>/opt/backdate.sh</code> <code>/opt/backdate.sh</code>
- 
-You need to be using backup. 
  
 ==== Manual Backup ===== ==== Manual Backup =====
Line 56: Line 56:
 <code>backdate.sh</code> <code>backdate.sh</code>
  
-==== Access a Backup ====+==== Restore Previous Backup ====
  
-Backup files are normally saved in the tce directorywhich may be somewhere like /mnt/sda1/tce.+To restore a previous backupremove mydata.tgz, and rename the backup you want to restore to mydata.tgz.
  
-To access the contents of a backup, create a new directory and copy the backup file to itOpen the terminal and type+If using encrypted backup, remove mydata.tgz.bfe, and rename the backup you want to restore to mydata.tgz.bfe.
  
-<code>cd directory +Restart the computer for it to be loaded.
-tar -xvf backup-name</code>+
  
-==== Restore a Previous Backup ==== 
- 
-To restore a previous backup, remove mydata.tgz, and rename the backup you want to restore mydata.tgz. 
- 
-Restart the computer for it to be loaded. 
  
Print/export
QR Code
QR Code wiki:backup_date (generated for current page)