The most popular way of backing up your Linux system are rsync and dump. The difference is that when using dump you need to work on a full image, where the rsync allows you to access individual files.
Backup using RSYNC command
From your local machine:
rsync -chavzP --stats user@remote.host:/path/to/copy /path/to/local/storage
From your local machine with a non-standard ssh or rsh port:
rsync -chavzP -e "ssh -p $portNumber" user@remote.host:/path/to/copy /local/path
On local network
rsync -chavzP -e "rsh -p $portNumber" user@remote.host:/path/to/copy /local/path
Or from the remote host, assuming you really want to work this way and your local machine is listening on SSH:
rsync -chavzP --stats /path/to/copy user@host.remoted.from:/path/to/local/storage
a fast, versatile, remote (and local) file-copying tool
-c, --checksum
This changes the way rsync checks if the files have been changed and are in need of a transfer.
Without this option, rsync uses a "quick check" that (by default) checks if each file’s size and
time of last modification match between the sender and receiver. This option changes this to
compare a 128-bit checksum for each file that has a matching size. Generating the checksums means
that both sides will expend a lot of disk I/O reading all the data in the files in the transfer
(and this is prior to any reading that will be done to transfer changed files), so this can slow
things down significantly.
The sending side generates its checksums while it is doing the file-system scan that builds the
list of the available files. The receiver generates its checksums when it is scanning for changed
files, and will checksum any file that has the same size as the corresponding sender’s file:
files with either a changed size or a changed checksum are selected for transfer.
Note that rsync always verifies that each transferred file was correctly reconstructed on the
receiving side by checking a whole-file checksum that is generated as the file is transferred, but
that automatic after-the-transfer verification has nothing to do with this option’s
before-the-transfer "Does this file need to be updated?" check.
For protocol 30 and beyond (first supported in 3.0.0), the checksum used is MD5. For older
protocols, the checksum used is MD4.
-h, --human-readable
Output numbers in a more human-readable format. This makes big numbers output using larger units,
with a K, M, or G suffix. If this option was specified once, these units are K (1000), M
(1000*1000), and G (1000*1000*1000); if the option is repeated, the units are powers of 1024
instead of 1000.
-a, --archive
This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to
preserve almost everything (with -H being a notable omission). The only exception to the above
equivalence is when --files-from is specified, in which case -r is not implied.
Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You
must separately specify -H.
-v, --verbose
This option increases the amount of information you are given during the transfer. By default,
rsync works silently. A single -v will give you information about what files are being transferred
and a brief summary at the end. Two -v options will give you information on what files are being
skipped and slightly more information at the end. More than two -v options should only be used if
you are debugging rsync.
Note that the names of the transferred files that are output are done using a default --out-format
of "%n%L", which tells you just the name of the file and, if the item is a link, where it points.
At the single -v level of verbosity, this does not mention when a file gets its attributes
changed. If you ask for an itemized list of changed attributes (either --itemize-changes or
adding "%i" to the --out-format setting), the output (on the client) increases to mention all
items that are changed in any way. See the --out-format option for more details.
-z, --compress
With this option, rsync compresses the file data as it is sent to the destination machine, which
reduces the amount of data being transmitted -- something that is useful over a slow connection.
Note that this option typically achieves better compression ratios than can be achieved by using a
compressing remote shell or a compressing transport because it takes advantage of the implicit
information in the matching data blocks that are not explicitly sent over the connection.
See the --skip-compress option for the default list of file suffixes that will not be compressed.
-P The -P option is equivalent to --partial --progress. Its purpose is to make it much easier to
specify these two options for a long transfer that may be interrupted.
-e, --rsh=COMMAND
This option allows you to choose an alternative remote shell program to use for communication
between the local and remote copies of rsync. Typically, rsync is configured to use ssh by
default, but you may prefer to use rsh on a local network.
If this option is used with [user@]host::module/path, then the remote shell COMMAND will be used
to run an rsync daemon on the remote host, and all data will be transmitted through that remote
shell connection, rather than through a direct socket connection to a running rsync daemon on the
remote host. See the section "USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION" above.
Command-line arguments are permitted in COMMAND provided that COMMAND is presented to rsync as a
single argument. You must use spaces (not tabs or other whitespace) to separate the command and
args from each other, and you can use single- and/or double-quotes to preserve spaces in an
argument (but not backslashes). Note that doubling a single-quote inside a single-quoted string
gives you a single-quote; likewise for double-quotes (though you need to pay attention to which
quotes your shell is parsing and which quotes rsync is parsing). Some examples:
-e 'ssh -p 2234'
-e 'ssh -o "ProxyCommand nohup ssh firewall nc -w1 %h %p"'
(Note that ssh users can alternately customize site-specific connect options in their .ssh/config
file.)
You can also choose the remote shell program using the RSYNC_RSH environment variable, which
accepts the same range of values as -e.
See also the --blocking-io option which is affected by this option.
Local: rsync [OPTION...] SRC... [DEST]
Access via remote shell:
Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
Access via rsync daemon:
Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
See man rsync
for an explanation of my usual switches, or better, check command at explainshell.com
Use scripts to automate backups
There are many open source command line and GUI tools for automating and organizing your backup tasks.
CMD backup tools
rsnapshot
Homepage: https://rsnapshot.org/
Github: https://github.com/rsnapshot/rsnapshot
Video tutorial: https://www.youtube.com/watch?v=cbDgXkcDq-I (backup remote CentOS to localhost)
Restic
Homepage: https://restic.net/
GitHub: https://github.com/restic/restic
Backup Windows video tutorial:
https://www.youtube.com/watch?v=GviqKHx8Aoo
Backup Linux video tutorial:
https://www.youtube.com/watch?v=MzJbSf7GQ1E
GUI server / client tool for backing up Windows and Linux PC)
UrBackup Backup solution
Homepage: https://www.urbackup.org/
Duplicati Backup solution
Homepage:https://www.duplicati.com/
Local Manual backup
Rescuezilla for Clonzilla
Rescuezilla is basically a GUI for Clonezilla. Both programs are compatible and can be run from USB stick without an installation.
https://clonezilla.org/downloads.php
https://rescuezilla.com/features
Backup Linux distribution before upgrading the system
Check system version
hostnamectl
Check file system. This must be the same as backup server.
df -Th | grep "^/dev"
Create a list of excluded folders such:
/boot
/dev
/tmp
/sys
/proc
/backup
/home/backup
/etc/fstab
/etc/mtab
/etc/mdadm.conf
/etc/sysconfig/network*
sudo rsync -vPa -e 'ssh -o StrictHostKeyChecking=no' --exclude-from=/root/excluded.txt / [REMOTE-IP-OF-THE-BACKUP-SERVER]:/
https://www.youtube.com/watch?v=cbDgXkcDq-I
https://webhostinggeeks.com/howto/how-to-upgrade-from-centos-7-to-centos-8/
https://www.slurp-ramen.com/cpanel-whm/clone-a-centos-server-using-rsync/