Linux Backup and Recovery Basics _linux

Source: Internet
Author: User
Tags what file system ssh
The UNIX system records these three different times for each file, the first one is mtime, that is, the modification time. Whenever the contents of a file are changed, the value of the Mtime is modified accordingly. The second one is Atime, which is the access time. As long as the file is accessed (for example, run or read), it is modified. The third is CTime, which is the change time. When a file's properties change (such as changing permissions or all relationships), the value of the CTime is changed. Administrators use CTime to find hackers.
Backup will change ATIME,TAR,CPIO,DD will do this, and dump reads the file system from the original device, so it does not
Will change atime.
The syntax of the dump.
Dump LEVELUNBDSF blkg-factor density size device-name file_system
Example:
Full backup of/home to a local tape drive called/DEV/RMT/0CBN.
# dump 0UNBDSF 126 141000 11500/dev/rmt/0cbn/home
Completely back up the/home to a/backup/home.dump optical CD drive.
# dump 0UNBDSF 126 141000 11500/backup/home.dump/home
The above command consists of three options that do not require arguments (0,U and N) and four options that require a single collaboration parameter (B,d,s and
f) composition.
Command options:
0---9 Specifies the level of backup that the dump should take.
b Specifies the block factor on which the dump should be used.
u Specifies the dump update dumpdates file.
N notifies members of the operator group when completing the operation.
D (density) and s (size) tells how large the dump backup volume is, and dump uses these numbers to estimate
What tape.
F tells dump what device to use.
W,w tells dump to perform an airlift line to tell you what file system needs to be backed up.
To avoid trans-volume dump.
Restore's syntax
Restore [trxi]vbsfy blocking-factor file-number Device-name
Example:
To recover the entire contents of a dump tape backup (located in/DEV/RMT/0CBN) that was created using block factor 32.
# Restore Rvbfy 32/DEV/RMT/0CBN
There is a dump tape created in/DEV/RMT/0CBN using block factor 32, if you want to recover the text from the tape
Pieces of/etc/hosts and/etc/passwd.
# Restore Xvbfy 32/dev/rmt/0cbn./etc/hosts/etc/passwd
Create a content table
# Restore TFY Device >/tmp/dump.list
Command options:
Determine the type of restore
T displays the contents of the volume.
R indicates that the entire contents of the volume should be restored to the current working directory.
x extracts only the files listed after the command.
I allow interactive restores to be performed.
Determine the behavior of restore
V Specify verbose output
The number of tape files skipped before s read
B Block factor
f The file name of the backup drive.
The y recovery process prohibits questioning.
Backup and recovery using the Cpio tool
The syntax of the backup
CPIO-O[ABCV]
The syntax of the recovery
Cpio-i[btv][patterns]
Example:
Create a full backup of the/home on a local tape.
# Cd/home
# Touch Level.0.cpio.timestamp make incremental backups possible. Establish a time reference point.
# Find. -PRINT|CPIO-OACVB > Device device can be an optical or CD device.
# Touch Level.1.cpio.timestamp Time reference point for incremental backups.
# Find. Newer LEVEL.1.CPIO.TIMESTAMP-PRINT|CPIO-OACVB >device
Creates a full backup of the/home on a remote tape.
# Cd/home
# Find. -print|cpio-oavb| (rsh remote_system dd of=device bs=5120)
Cpio backups Use an absolute path (find/home/file) to limit the flexibility of recovery. It can only be restored to/home/file.
If you use a relative path (find home/file) You can restore it to any place.
Command options
Backup classes
o Create a backup
A resets the atime to the value before the backup
C with ASCII header format
V For detailed information output
B,C Specifies the block size, which is mutually exclusive.
Recovery class
I specifies the input mode, which must be the first of the list of commands.
T generates a content table and does not actually operate.
K Skip over bad zone
D Create a table of contents when needed
M restores the original modification time when the file is backed up, otherwise the default action is to set the modified time of the recovered file
For the new modified time
U unconditionally overwrite all files
"*pattern" Restores files that match the pattern
F "*pattern" restores files that do not match the pattern
R Interactive Rename file name
2004/02/12
Basic syntax for the TAR command
# Tar-[CX]VF device pattern
Command options
C Create an archive
V Detail Output
W verifies the archive file
B Block factor
F output to the device referred to in the device parameter, device can be a file, CD-ROM, tape or standard output
(stdout)
Pattern patterns match like "A *"
X Restore an Archive
M normally, the recovered files retain their modified time before archiving, which is used to change
As a recovery time, this is exactly the opposite of the behavior of the Cpio command.
o Set the owner of the recovered file to you. This is the default behavior for non-root users, unless you use this option to
Otherwise, the files extracted by root are owned by the users and groups that are stored in the TAR document.
P By default, tar does not recover all file properties. The license for the file is determined by the current umask, not
Determined by the license of the original file, including the setuid and sticky bits. This option tells Tar to use the original file's license.
D can make a diff comparison between the archive and the file system.
A Reset access time
F runs a script at the end of the volume, which can be used for automatic volume swapping.
Z-Z automatically invokes compress and gzip programs
DD Command Basic syntax
# dd If=device Of=device bs=blocksize
if= Specifies the input file, which is the file from which DD copies data. It can be a file or a raw partition that needs to be backed up.
If the data is read from stdin, then the parameter does not need to be specified.
of= Specifies the output file, which is the destination where the DD sends the data. It can be a file that needs to be backed up or a raw partition, such as
The parameter does not need to be specified if the data is read from the stdout.
BS Specifies the block size, that is, the amount of data transferred during an I/O operation.
Remote backup using DD and rsh and SSH (the GNU tar and GNU cpio command can read remote devices)
Read a backup on a remote device
# rsh Remote_host "dd if=device ibs=blocksize" |tar XVBF-
# ssh Remote_host "dd if=device bs=blocksize" |tar XVBF-
# ssh Remote_host "dd if=device bs=blocksize" |restore RVF-
# ssh Remote_host "dd if=device bs=blocksize" |CPIO-ITV
Write Backup to remote device
# TAR-CVF-. | (rsh remote_system dd of=device obs=block_size)
# dump 0BDSF 100000 100000-|ssh remote_host "dd if=device bs=64k"
# TAR-CVF-|ssh remote_host "dd if=device bs=10k"
# CPIO-OACVB |ssh remote_host "dd if=device bs=5k"
Linux Bare Metal Recovery method:
1, backup important metadata # Fdisk-l >/etc/fdisk-l.txt
2, with local tools backup system # CD/; Tar CF-. |gzip-c >/backup/xxx.tar.gz
3, System damage, with other media guidance system (guide plate, Knoppix, etc.).
4, with the metadata on the hard disk of this line partition and format.
The metadata file is extracted #gzip-dc/xxx/xxx.tar.gz|tar-xvf-./etc/fstab./etc/fdisk-l.txt
Partition # FDISK/DEV/SDA
Create File System # MKE2FS/DEV/SDA1
5, restore the operating system Information # Gzip-dc/xxx/xxx.tar.gz|tar XF-
6, restore the boot block on the new root disk
ORACLE (offline) Cold backup
1. Close the database and abort all processes that allow access to the database.
2, the Backup tool to backup files (Tar,dd,cpio)
ORACLE (online) hot standby necessary steps
1. Request Oracle's list of all tablespaces and data files.
2. Request the location where the Oracle archive log is stored.
3. Request the location where Oracle control files are stored (optional).
4, put all the table space in the backup mode, but with alter Tablespace Tablespace_name BEGIN
Backup command.
5. Copy data files from each table space to disk or tape.
6, remove the various table space backup mode, you can use ALTER tablespace tablespace_name end
Backup command.
7, switch redo log files.
8, backup control files, you can use the Backup controls File command.
9, Manual copy control file (optional).
10, manual reproduction online redo log.
11. Ensure that all archived redo logs are kept intact during the backup period.
Description
When a table space is placed in Backup mode, the following events occur:
1. Oracle checks the table space to store all changes from memory to disk.
2. The SCN identification of each data file in the table space is "Frozen" at the current value, even if the data file is further updated,
The SCN value is not updated until backup mode is removed.
3. Oracle shifts the image of the database block from the record to the record redo log. No longer records a particular block is
How to change, but to record the entire change in the image of the block. This is the rapid growth of the redo log in the hot backup process
Because
Oraback.sh script support features for automatic backups:
1, backup disk or tape.
2, automatic detection of database configuration.
3, based on the file system or the original partition backup database.
4, multitasking, you can reduce the backup time to 75%.
5, the use of mail to send success or error notification.
6. Backup one or more instances of the oratab.
Introduction to Using methods
1, backup all instances;
# Oraback. Sh
2, backup one or more instances, to take the parameter oracle_sid;
# Oraback. SH Oracle_sid1 oracle_sidn
3. If you want to schedule a backup at a time specified in oraback.conf, then bring the at:
# Oraback. SH at Oracle_sid1 oracle_sidn
Install oraback.sh, first will oraback.sh, CONFIG. Guess and localpath.sh placed in a
directory, and then check the following values for a specific location in the script header.
BINDIR installs the oraback.sh directory.
Oratab is the name and location of the Oratab file that is set to Oracle.
Oraconf is set to the name and location of the oraback.conf file.
Oraback. Conf configuration
1, HOSTNAME. Master System hostname, remove domain name (e.g. AAA.DOMAIN.COM becomes AAA)
2, skip if you skip all backups on this host tonight, you can enter "Skip" here
3. Cold day is a date that can be backed up on a daily basis (FRI, Friday), or monthly
One day (03, that is, the third day).
4, cold time to make a cool backup, using a 24-hour system.
5, Hot time in the day to make a warm backup, using a 24-hour system.
6. TYPE DEVICE non-wrapping tape device, backed up to tape. (If only disk backups are allowed, leave blank).
7, users are allowed to run the script list of user names, to | separate, such as oracle| DBA, white space means only allow
Oracle user run.
8, PARALLELISM simultaneous operation of the number of copies of data files, vacancy = 1.
9, Backup dir directory.
10, Y indicates that the file is compressed before writing to the disk.
11, mail DS message ID list, used to send a backup of the success or failure of the notification, between the "," number separated.
Restrict mode is required for full logical backups. Close the database and then use startup RESTRICT OPEN
Open the database, and then make a full export. After the export is completed, use alter DATABASE DISABLE restricted
Session to resume the connection.
Ji Cui
Mirror Redo Log All members of an active or current log group are lost, causing data loss.
Mirror redo log, the likelihood that all log group members are lost is very small.
Watch alert log mirroring control file using Archivelog mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.