Linux commands can back up folders. There are two commands for backing up folders: 1. cp command, which is used to copy files or folders. The syntax is "cp [options] source dest"; 2. dump command, which is used to back up the file system. The syntax is "cp [options] source dest". is "dump [-cnu][-0123456789]...".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
1. cp command
Linux cp (English full spelling: copy file) command is mainly used to copy files or Table of contents.
Syntax
cp [options] source dest
or
cp [options] source... directory
Parameter description:
-a: This option is usually used when copying a directory, it Preserve links, file attributes, and copy all contents of the directory. Its effect is equal to the dpR parameter combination.
-d: Keep the link when copying. The links mentioned here are equivalent to shortcuts in Windows systems.
-f: Overwrite an existing target file without giving a prompt.
-i: Contrary to the -f option, a prompt is given before overwriting the target file, asking the user to confirm whether to overwrite. The target file will be overwritten when answering y.
-p: In addition to copying the contents of the file, the modification time and access permissions are also copied to the new file.
-r: If the given source file is a directory file, all subdirectories and files in the directory will be copied.
-l: Do not copy files, just generate link files.
Use the command cp to copy all files in the current directory test/ to the new directory newtest. Enter the following command:
$ cp –r test/ newtest
Note: Users use this command to copy the directory When , you must use the parameter -r or -R.
2. Dump command
The Linux dump command is used to back up the file system.
dump is a backup tool program that can back up a directory or the entire file system to a specified device or into a large file.
Syntax
dump [-cnu][-0123456789][-b <区块大小>][-B <区块数目>][-d <密度>][-f <设备名称>][-h <层级>][-s <磁带长度>][-T <日期>][目录或文件系统] 或 dump [-wW]
Parameters:
-0123456789 Backup level.
-b
-B
-c Modify the default density and capacity of the backup tape.
-d
-f
-h
-n When backup work requires administrator intervention, send a notification to all users in the "operator" group.
-s
-T
-u After the backup is completed, record the backup file system, level, date and time in /etc/dumpdates.
-w Similar to -W, but only displays files that need to be backed up.
-W Display the files to be backed up and the level, time and date of the last backup.
Backup files to tape
# dump -0 -u /dev/tape /home/
The "-0" parameter specifies the backup level. "-u" requires that the corresponding information be stored in the file/ after the backup is completed. etc/dumpdates for records
Recommended learning:Linux video tutorial
The above is the detailed content of Can linux commands back up folders?. For more information, please follow other related articles on the PHP Chinese website!