Basic Linux backup and recovery knowledge

Source: Internet
Author: User
Tags what file system

The UNIX system records these three different times for each file. The first is the mtime, that is, the modification time. Whenever the file content is changed, the mtime value is modified accordingly. The second is atime, that is, the access time. As long as the file is accessed (such as running or reading), it will be modified. The third is ctime, that is, the change time. The ctime value is changed when the file attributes change (for example, permission change or all relationships. The Administrator uses ctime to find hackers.
The backup changes atime, tar, cpio, and DD. Dump reads the file system from the original device, so it does not
Will change atime.
Dump syntax.
Dump levelunbdsf blkg-factor density Size Device-name file_system
Example:
Back up/home to a local tape drive called/dev/RMT/0cbn.
# Dump 0 unbdsf 126 141000 11500/dev/RMT/0cbn/home
Back up/home to an optical CD drive called/backup/home. Dump.
# Dump 0 unbdsf 126 141000 11500/backup/home. Dump/home
The preceding command consists of three options (0, U and N) that do not need a parameter and four options (B, d, S and
F.
Command Options:
0---9 specifies the backup level that dump should perform.
B specifies the block factor that dump should use.
U specifies dump to update the dumpdates file.
N notify the operator group members when completing the operation.
D (density) and S (size) Tell dump how large the backup volume is. Dump uses these numbers to estimate the size of the backup volume.
Tape.
F. Tell dump what device to use.
W, w tell dump to execute an air transportation operation To Tell You What file system needs to be backed up.
Avoid cross-volume dump.
Restore syntax
Restore [trxi] vbsfy blocking-factor file-number device-name
Example:
You need to restore all the contents of a dump tape backup (in/dev/RMT/0cbn) created using block factor 32.
# Restore rvbfy 32/dev/RMT/0cbn
There is a dump tape created using block factor 32 located in/dev/RMT/0cbn. If you want to restore the file from this tape
/Etc/hosts and/etc/passwd.
# Restore xvbfy 32/dev/RMT/0cbn./etc/hosts./etc/passwd
Create content table
# Restore TFY device>/tmp/dump. List
Command Options:
Determines the Restore Type
T displays the volume content.
R indicates that the entire volume content should be restored to the current working directory.
X extracts only the files listed below the command.
I allows interactive recovery.
Determine restore Behavior
V specifies the detailed output
S the number of tape files skipped before reading
B Factor
F. Name of the backup drive.
Y. query is forbidden during recovery.
Use cpio tool for backup and recovery
Backup syntax
Cpio-O [abcv]
Restored syntax
Cpio-I [BTV] [patterns]
Example:
Create a full backup of/home on a local tape.
# Cd/home
# Touch level.0.cpio. timestamp makes Incremental Backup possible. Create a time reference point.
# Find.-print | cpio-oacvb> the device can be an optical or CD device.
# Touch level.1.cpio. timestamp: time reference point for Incremental backup.
# Find. Newer level.1.cpio. timestamp-print | cpio-oacvb> Device
Create a full backup of/home on a remote tape.
# Cd/home
# Find.-print | cpio-oavb | (RSH remote_system dd OF = device BS = 5120)
The absolute path (find/home/file) for cpio backup limits 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 location.
Command Options
Backup class
O create a backup
A resets atime to the value before backup.
C uses the ASCII Header Format
V for detailed information output
B and C specify the block size. They are mutually exclusive.
Recovery class
I indicates the input mode, which must be the first in the command list.
T generate the content table, which is not actually operated.
K skip the bad zone
D. Create a directory as needed
M: The original modification time when the file backup is restored. Otherwise, the default action is to set the modification time of the recovered file.
New modification time
U unconditionally overwrites all files
"* Pattern" Restore Files matching this pattern
F "* pattern" Restore files that do not match this pattern
R interactive rename file name
2004/02/12
Tar command syntax
# Tar-[CX] VF device pattern
Command Options
C. Create an archive
V detailed information output
W. Verify the archived files
B Factor
F indicates the device output to the device parameter. The device can be a file, a CD, a tape, or a standard output.
(Stdout)
Pattern matching, for example, "*"
X restore an archive
M under normal circumstances, the recovered files will keep their modification time before the archive, select this option to change the modification time
To the recovery time, which is the opposite of the cpio command.
O set the owner of the recovered file to you. This is the default behavior for non-root users, unless this option is used,
Otherwise, all files extracted by the root user are stored in the user and group in the TAR document.
P by default, tar does not restore all file attributes. The file license is determined by the current umask, rather
Determined by the license of the original file, including the setuid and sticky bits. This option tells tar to use the permission of the original file.
D. Perform a diff comparison between the archive and the file system.
A. Reset the access time
F runs a script when the volume ends, which can be used for automatic volume switching.
Z automatically calls compress and Gzip Program
Basic dd command syntax
# Dd If = Device of = device BS = blocksize
If = specifies the input file, that is, the file from which dd copies data. It can be a file or original partition to be backed up,
If you read data from stdin, you do not need to specify this parameter.
Of = specifies the output file, that is, the destination of data sent by DD. It can be a file or original partition to be backed up, such
If you read data from stdout, you do not need to specify this parameter.
BS specifies the block size, that is, the amount of data transmitted in one I/O operation.
Remote Backup Using DD and RSH and SSH (GNU Tar and GNU cpio command can read remote devices)
Reads backups from remote devices.
# 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 the backup to a remote device
# Tar-CVF-. | (RSH remote_system dd OF = device obs = block_size)
# Dump 0 bdsf 64 100000 100000-| SSH remote_host "dd If = device BS = 64 K"
# Tar-CVF-| SSH remote_host "dd If = device BS = 10 K"
# Cpio-oacvb | SSH remote_host "dd If = device BS = 5 K"
Linux bare metal recovery method:
1. Back up important metadata # fdisk-L>/etc/fdisk-l.txt
2. Use a local tool to back up the system # cd/; tar CF-. | gzip-C>/backup/xxx.tar.gz
3. The system is damaged. Use other media to guide the system (BOOT disk, knoppix, etc ).
4. Partition and format the hard disk row with metadata.
Solve the metadata file # gzip-DC/XXX/xxx.tar.gz | tar-xvf-./etc/fstab./etc/fdisk-l.txt
Partition # fdisk/dev/SDA
Create a file system # mke2fs/dev/sda1
5. Restore 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. Shut down the database and stop all processes that allow access to the database.
2. Use a backup tool to back up files (TAR, DD, cpio)
Oracle (online) Hot Standby steps
1. List of all tablespaces and data files requested from Oracle.
2. the location where the Oracle archive log is stored.
3. Location of the Oracle control file to be stored (optional ).
4. Place all tablespaces in backup mode and use alter tablespace tablespace_name begin
Backup command.
5. copy the data files in each tablespace to a disk or tape.
6. Remove the backup mode of each tablespace. You can use alter tablespace tablespace_name end.
Backup command.
7. Switch to the redo log file.
8. Backup control file. You can use the backup control file command.
9. manually copy the control file (optional ).
10. manually copy online redo logs.
11. Ensure that all archived redo logs during Backup are well preserved.
Note:
When the tablespace is in backup mode, the following events occur:
1. Oracle checkpoint tablespace stores all changes from memory to disk.
2. the scn id of each data file in the tablespace is "Frozen" at the current value, even if the data file is further updated,
The SCN value will not be updated until the backup mode is removed.
3. Oracle changes the database block image from a complete record to redo logs. No longer records a specific block
How to change, but record the image of the entire changed block. This is the original reason for the rapid growth of redo logs in the hot backup process.
Because.
The automatic backup oraback. Sh script supports the following features:
1. Back up disks or tapes.
2. automatically checks the database configuration.
3. Back up the database based on the file system or the original partition.
4. Multi-task: reduce the backup time to 75%.
5. Send success or error notifications by email.
6. Back up one or more instances in oratab.
Usage
1. Back up all instances;
# Oraback. Sh
2. To back up one or more instances, add the oracle_sid parameter;
# Oraback. Sh oracle_sid1 oracle_sidn
3. If you want to schedule a backup at a certain time point specified in oraback. conf, The:
# Oraback. Sh at oracle_sid1 oracle_sidn
To install oraback. Sh, first place oraback. Sh, config. Guess, and localpath. Sh in
Directory, and then check the following values in the specific position of the script header.
Bindir directory for installing oraback. Sh.
Set oratab to the name and location of the Oracle oratab file.
Set oraconf to the name and location of the oraback. conf file.
Oraback. conf configuration
1. hostname. Master System host name. Remove the domain name (for example, AAA. domain. com is changed to AAA)
2. If skip skips all backups on the host this evening, you can enter "Skip" here"
3. The cold backup date of cold day, which can be one day of a week (Fri, that is, Friday) or every month
Of a day (03, that is, the third day ).
4. The time for cold backup using cold time, in the 24-hour format.
5. Hot time: the hot backup time in one day, in the 24-hour format.
6. The type device is not a rewound tape device and is backed up to the tape. (If only disk backup is allowed, leave it blank ).
7. Users allows a list of usernames for script execution, separated by |, for example, Oracle | DBA. Blank: only allow
Oracle user run.
8. Number of copies of data files simultaneously run by parallelism. Vacancy = 1.
9. Backup dir Backup Directory.
10. y indicates that files are compressed before being written to the disk.
11. Mail DS email ID list, which is used to send notifications about whether the backup is successful or not, separated.
The restrict mode is required for full logical backup. Close the database and use startup restrict open
Open the database and perform full export. After the export is complete, use alter database disable restricted
Session.
Collection
Image redo logs: all the members of an active or current log group are lost, resulting in data loss.
Image redo logs make all log group members less likely to be lost.
Observe that the alarm log image control file uses 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.