Before knowing the difference, what we need to know is what is back up and why we need to do backup?
AÂ backupÂ is a copy of data from your database that can be used to reconstruct that data in case the original is lost or corrupted. In terms of computer we can say, backupÂ means to copy files to a second medium (can be a disk) as a precaution in case the first medium fails.
In Linux we use the commands such as rsync, tar, etc
rsync â€” a fast , versatile, remote (and local) file-copying tool.
It is widely used for backups and mirroring and as an improved copy command for everyday use.
Syntax: rsync [option] source destinationÂ Â Â //the source and destination can be remote or local but as here we are discussing about local so we will use them as local
|# rsync â€“zvr /data1 /backup1Â Â Â Â Â Â Â Â Â Â Â Â Â Â //here we are taking compressed form of backup of data1|
Synchronous backup time stamp is preserved, this is achieved by archive mode .So as to use it we write rsync â€“a where â€œaâ€ preserves symbolic link , permissions , timestamp ,owner and group.
|#rsync â€“azvr /data1 /backup1|
Now, to check the timestamp we will use the command
|# ls â€“l /data1 /backup // in both backup types you will get the difference|
drwxr-xr-x. 2 root root 4096 JulÂ 2 23:04 data1Â
/data1: Â Â
-rw-r–r–. 1 root rootÂ 6 JulÂ 2 22:00 a
-rw-r–r–. 1 root root 13 JulÂ 2 23:04 b
The best feature of rsync is that if any changes occurs in the original file and you want this change to be a part of the backup made then only the change is copied or we can say incremented in the backup made.
This backup is achieved by using the tar command which is used to convert files into archive or tarballs .
Syntax: tar [option] [archivename] [filename]
|# tar â€“cpvf xyz.tar /etcÂ|
In case of asynchronous backup we need to know which file has been changed due to which mostly we use synchronous backup .We can also test or view the archive by using options â€“t , -list etc .By using tar you can compress files in .bz2 or .gz by using option j and z respectively.
|Difference between Hot backup and Cold backup|
Hot backup and Cold backup are both used for system backups, these backups are created for any sort of media failure. The lvm snapshot is used in this sector basically.
>> Hot backups are the one which are taken when the database is active.
>> The database must be in archivelog mode.
>> This is used where data is not that important as we canâ€™t use this type of backup in banking
>> You cannot shutdown in normal or immediate mode a hot backup if it is started, if you do so youâ€™ll get an error message that you are in backup mode.
>> tablespaces in this can be backed up on the basis of schedules.
>> It is done when the database is not active i.e. the system is in shutdown mode.
>> Here, we can have complete restoration from the copy.
>> It is a physical backup of the database which is achieved when the system is shutdown normally not aborted or immediately.
>> In this we use the command such as dd, tar, fbackup etc.
>> It provides consistency.
MAJOR DIFFERENCE BETWEEN THEM ARE Â :
- 1.Â Â Â To achieve hot backup we need archivelog mode whereas in cold backup we create the backup at the same time.
- 2.Â Â Â In hot backup we can schedule the tablespaces for backup which is not possible in cold backup.
- 3.Â Â Â We need to inform the system when backup starts and completes in case of different tablespaces scheduled for backup in hot backup but not in cold backup.
- 4.Â Â Â Hot backup are used where the system are large and the processing canâ€™t be stopped in any case.
- 5.Â Â Â Cold backup are used where data plays vital role i.e. the processing can be stopped for some duration.