X

Rate Us :



Share with Friends :

Menu

Backup :

It is the process of copying data to another location.

It is used to prevent the loss of data.

Users can take the backup of their own data.

The complete backup can only be taken by root user.


Type of backup :


  • Full backup :
  • It refers to taking backup of complete data.


  • Incremental backup :
  • It includes files that were changed since the last backup.


Commands for backup :


  • Dump




  • Scp




  • Cronjob




  • At job




  • Backup using tar command :


    [root@localhost~]#tar <option> <destination> <source> This command is used to backup and restore. Options : -c => create -x => extract/restore -v => verbose -f => file -t => table of content -z => zip Example : Create a directory - [root@localhost~]#mkdir /dir1 Copying the system data to local directory - [root@localhost~]#cp -r /etc/* /dir1 To check directory size - [root@localhost~]#du -sh /dir1 Backup without compress - [root@localhost~]#tar -cvf /home/data.tar /dir1 Backup with compress - [root@localhost~]#tar -cvzf /home/data.tar.gz /dir1 To check the backup file size - [root@localhost~]#du -sh /home/data* Restore the data if the data is lost (not compressed) - [root@localhost~]#tar -xvf /home/data.tar -c /var [-c is used to restore the data into different directory] Restore the data if the data is lost (compressed) - [root@localhost~]#tar -xvzf /home/data.tar.gz -c /var [automatically uncompress the file and then restore]


    at command :

    It is used to run specific task with specific time.


    Example : Check the system correct date and time - [root@localhost~]#date [lets say, Tue Jan 26 04:28:17 PST 2016] Running task - [root@localhost~]#at 04:30 at> mkdir dir1 [Ctrl + d to save and exit] [So, at 04:30 a new directory will be created named as dir1] To check all the task information with the number - [root@localhost~]#atq To remove any task - [root@localhost~]#atrm <task number>

    scp command :

    It is used to copy the data from local system to remote system.


    Create backup using scp command - [root@localhost~]#scp <option> <source_dir> <destination_ip>:<location> Options : -r => recursive -v => verbose Example : Copy local system data to remote system - [root@localhost~]#scp -r /etc 192.168.0.182:/root/Desktop Restore the backup created using scp command - [root@localhost~]#scp <option> <destination_ip>:<location> <local_dir> Options : -r => recursive -v => verbose Example : Copy remote system data to local system - [root@localhost~]#scp -r 192.168.0.182:/opt/* /root/Desktop


    Create backup using dump command - [root@localhost~]#dump <option> <destination> <source> Options : -n => n is an integer between 0 and 9 [0 means full backup] -u => Update dump database file [/etc/dumpdates] -f => File_name Restore the backup created using dump command - [root@localhost~]#restore <option> <destination> <source> Options : -t => Table of contents -r => Restore -f => File_name