How to back up whole Linux server?

TheCompWiz

Well-known member
Registered
Joined
Apr 20, 2016
Messages
130
Points
18
Hi everyone, Can you tell me how to back up whole my Linux server? I mean I want to backup all files and databases on entire server and when I reinstall my server then I can restore that backup and I can use it immediately whiteout re-configure or installations?
 

AECHostingNet

Member
Registered
Joined
Apr 25, 2018
Messages
29
Points
3
You're referring to a bare metal restore. You'll want to look around for backup software that can do this for you. R1soft seems to be one of the more popular choices among sysadmins.

I know from my experience backup software tends to be frustrating. Things can happen and your backups may not be reliable. R1soft tends to be one that sucks the least and is somewhat affordable.
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
Hi everyone, Can you tell me how to back up whole my Linux server? I mean I want to backup all files and databases on entire server and when I reinstall my server then I can restore that backup and I can use it immediately whiteout re-configure or installations?
Hello,
you can make a snapshot of your whole disk or partition with the command dd :
Bash:
# /dev/sda is the disk to backup 
dd if=/dev/sda ibs=4096 conv=noerror | gzip > backup.image.gz
Then you will be able to restore it with
Bash:
zcat backup.image.gz | dd of=/dev/sda ibs=4096
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
Where to run this?
At root account and in SSH?
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
I tried to run your command but it doesn't tell me where it will be completed or how many percents it saved.

When I cancel the command with crtl+C then it displayed this

Code:
[root@myzopi ~]# dd if=/dev/sda ibs=4096 conv=noerror | gzip > backup.image.g                                   z

^C72785+0 records in
582272+0 records out
298123264 bytes (298 MB) copied, 7.84582 s, 38.0 MB/s

[root@myzopi ~]# dd if=/dev/sda ibs=4096 conv=noerror | gzip > backup.image.gz

^C198401+0 records in
1587200+0 records out
812646400 bytes (813 MB) copied, 24.8979 s, 32.6 MB/s
I like to see how it runs and when it will be finished like I run zip and unzip command :)
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
VirtuBox
Hello,
you can add the argument -v in front of the command gzip > backup.image.gz but it will not give you the expected time required to perform the backup. To perform a full disk backup, it can require a lot of time. You will also have to make sure your server have enough storage available to store the backup
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
I tried to add -v but it did not work
[root@myzopi ~]# dd if=/dev/sda ibs=4096 conv=noerror | -v gzip > backup.image.gz
-bash: -v: command not found
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
I run this command but it was error

Code:
[root@myzopi ~]# dd if=/dev/sda ibs=4096 conv=noerror status=progress | gzip > backup.image.gz
dd: invalid status flag: `progress'
Try `dd --help' for more information.
I tried to run dd --help to see what I can get from this command but didn't -v parameter there

[root@myzopi ~]# dd --help
Usage: dd [OPERAND]...
or: dd OPTION
Copy a file, converting and formatting according to the operands.

bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=)
cbs=BYTES convert BYTES bytes at a time
conv=CONVS convert the file as per the comma separated symbol list
count=N copy only N input blocks
ibs=BYTES read BYTES bytes at a time (default: 512)
if=FILE read from FILE instead of stdin
iflag=FLAGS read as per the comma separated symbol list
obs=BYTES write BYTES bytes at a time (default: 512)
of=FILE write to FILE instead of stdout
oflag=FLAGS write as per the comma separated symbol list
seek=BLOCKS skip BLOCKS obs-sized blocks at start of output
skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input
status=WHICH WHICH info to suppress outputting to stderr;
'noxfer' suppresses transfer stats, 'none' suppresses all

BLOCKS and BYTES may be followed by the following multiplicative suffixes:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

ascii from EBCDIC to ASCII
ebcdic from ASCII to EBCDIC
ibm from ASCII to alternate EBCDIC
block pad newline-terminated records with spaces to cbs-size
unblock replace trailing spaces in cbs-size records with newline
lcase change upper case to lower case
nocreat do not create the output file
excl fail if the output file already exists
notrunc do not truncate the output file
ucase change lower case to upper case
sparse try to seek rather than write the output for NUL input blocks
swab swap every pair of input bytes
noerror continue after read errors
sync pad every input block with NULs to ibs-size; when used
with block or unblock, pad with spaces rather than NULs
fdatasync physically write output file data before finishing
fsync likewise, but also write metadata

Each FLAG symbol may be:

append append mode (makes sense only for output; conv=notrunc suggested)
direct use direct I/O for data
directory fail unless a directory
dsync use synchronized I/O for data
sync likewise, but also for metadata
fullblock accumulate full blocks of input (iflag only)
nonblock use non-blocking I/O
noatime do not update access time
noctty do not assign controlling terminal from file
nofollow do not follow symlinks
count_bytes treat 'count=N' as a byte count (iflag only)

Sending a USR1 signal to a running `dd' process makes it
print I/O statistics to standard error and then resume copying.

$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid
18335302+0 records in
18335302+0 records out
9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s

Options are:

--help display this help and exit
--version output version information and exit

Report dd bugs to [email protected]
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'dd invocation'
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
I am not sure why it was error but I used Centos 6 on this VPS and have not installed any hosting control panels on it yet.
One more question, if I can backup whole my Linux server with this command, when i restore the file, it will restore all congratulations like DNS, files, data..etc?
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Gmeister4
I saw it there.
After I created the backup, what to do if I want to restore my server to the point before I made backup?
Do I need to reinstall my VPS before restore the backup file?
 

mobin

Well-known member
Registered
Joined
Jun 22, 2017
Messages
234
Points
28
Please note that the snapshot option will work only against of your data partition if you want to reinstall the OS for any specific reason. Also a customized system like cPanel, Plesk, etc this is not a complete solution. But of course this is the quickest if the server is under your direct configuration. That said....reinstall OS and no re-configuration do not match. If you reinstall the OS, that means the package installation and all should do again - you can only backup configuration in that case. Otherwise it will be still your old OS.

So to answer your actual question - as said, it will be based on your server environment and what all data you want to restore.
 

Nixtree

Well-known member
Registered
Joined
Jul 16, 2016
Messages
133
Points
28
I will always suggest to do backups only on account level rather than server level. Suppose you are initially in a Old Os say centos5 and your backups are taken like this, then if you wish to upgrade the Os or wish to change the Os , then it will not work. Also entire Os will take time to get restored.

For control panel based one I will suggest to get a copy of accounts in thier own platform like pkgaccount in case of cpanel, Plesk dumps in case of plesk etc which will help us to restore all its subitems and links as one domain will have 100s of references and we will not be able to manually handle all those references.

Your method will only work for those which you setup custom and not for cpanel/plesk/directadmin ones. If you can let us know the exact environment for which you need and also what scenarios you need to cover we can be more helpful to you.

Environment : Which Os and Which Control panel in use ?

1. you want single accounts to be restored ?
2. Speedy accounts restore of all accounts incase of Os reinstall
3. you want to have a single file to be restored ?
4. Single db to be restored ?
 

TheCompWiz

Well-known member
Registered
Joined
Apr 20, 2016
Messages
130
Points
18
I will always suggest to do backups only on account level rather than server level. Suppose you are initially in a Old Os say centos5 and your backups are taken like this, then if you wish to upgrade the Os or wish to change the Os , then it will not work. Also entire Os will take time to get restored.
For control panel based one I will suggest to get a copy of accounts in thier own platform like pkgaccount in case of cpanel, Plesk dumps in case of plesk etc which will help us to restore all its subitems and links as one domain will have 100s of references and we will not be able to manually handle all those references.
Your method will only work for those which you setup custom and not for cpanel/plesk/directadmin ones. If you can let us know the exact environment for which you need and also what scenarios you need to cover we can be more helpful to you.
Environment : Which Os and Which Control panel in use ?
1. you want single accounts to be restored ?
2. Speedy accounts restore of all accounts incase of Os reinstall
3. you want to have a single file to be restored ?
4. Single db to be restored ?
Environment : Which Os and Which Control panel in use ?
I like using Centos 6 for my Linux server
1. you want single accounts to be restored ?
Not only any accounts, I wanted to backup whole linux server on my VPS so when I restore the file, it will restore all configurations and data and I can use it immediately.
3. you want to have a single file to be restored ?
Yes, it is great if I can have a backup file and restore it with ssh.
4. Single db to be restored ?
Databases already included in the backup file.
 

Nixtree

Well-known member
Registered
Joined
Jul 16, 2016
Messages
133
Points
28
I have been using Dirvish for a customer for the last 6 years and I can see those are really good and handy. We add mysql backup dump script and cpanel pkgacount script skipping homedir and the backup we take is incremental one using dirvish.

So such a setup we can restore
one file,
one db,
one cpanel account using restore of the pkg account first and then restore the corresponding /home/user folder.
and if the entire server is gone, we can restore the account initially using cpanel pkg account backups and then we can rysnc the files and db using the backups with dirvish backup server

http://dirvish.org/

i like this very much and is very handy so far as an admin I really like to work from command line which give me more flexibility rather than going with r1soft front end interface.
 

vashishtha_serverguy

New member
Registered
Joined
Apr 24, 2018
Messages
6
Points
3
You can backup your whole Linux server using a simple command
Open your terminal and run this command :cool:
Code:
$ sudo rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt
 

David Beroff

Well-known member
Registered
Joined
Jun 14, 2016
Messages
1,498
Points
63
It will not backup mysql databases properly, you have to stop MySQL before making a copy if you want to make sure databases will not be corrupted.
you have to stop MySQL before making a copy if you want to make sure databases will not be corrupted.
@VirtuBox This will need to do when running backup for whole Linux server for every command?
 

Internet-Buff

Member
Registered
Joined
Aug 1, 2018
Messages
41
Points
8
I am using VPSrobots to manage my Linux server and site for a while. I backed up my entire server with VPSrobots to Amazon S3 storage before, it is really fast and easy to use. You can back up your site in real time, or create a schedule to back it up automatically.
 
Older Threads
Newer Threads
Replies
0
Views
1,521
Replies
6
Views
3,863
Replies
4
Views
4,118
Replies
2
Views
1,488
Latest Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top