How to Backup and Restore Ubuntu Server Using Tar in Terminal

  Рет қаралды 51,598

Odd Random Thoughts

Odd Random Thoughts

Күн бұрын

Backup up your Ubuntu server installation using the tar command via the terminal.
Two easy steps simplified
To Create the Backup Archive:
sudo tar -cvpzf yourbackupfilename.tar.gz --exclude=/path/to/backup/yourbackupfilename.tar.gz --one-file-system /
In the last part of the command a single forward slash will backup the entire root directory, or you can specify a certain directory to backup.
Restoring your backup:
sudo tar -xvpzf /path/to/yourbackupfilename.tar.gz -C /directory/to/restore/to --numeric-owner
If restoring a complete root directory backup the last section of this command would simply be a forward slash /
Reboot and enjoy.

Пікірлер: 79
@reindeboer7374
@reindeboer7374 5 жыл бұрын
Hey man, I really appreciate your work here, explaining every single thing without raising me questions. Very nice!
@Eofold
@Eofold 6 жыл бұрын
Wow. No need for expensive backup software. This method works like a charme. In combination with a crontab and grive this is the easiest and cheapest automated backup method ever. Thank you so so much for this video. You are awesome.
@lopoka1
@lopoka1 3 жыл бұрын
Very very clear and concise video, thank you for this video. You definitely deserve much more subs !
@dewmguy
@dewmguy 5 жыл бұрын
Sweet video. I hope i don't have to use it! Your explanation was 100% thorough and clear, you didn't ramble on or have an annoying intro, and your speaking skills are strong. Honestly a top 10 video for me on youtube. KZbinrs should use you as a reference on how to make a tutorial video.
@LachezarDolmov
@LachezarDolmov 3 жыл бұрын
Thank you very much! I didn't knew about the --one-file-system and have been excluding all directories manually. I'm gonna try this option as well :)
@treasuretron
@treasuretron 4 жыл бұрын
THIS WAS AWESOME!!! Perfect, this was exactly what I needed, thankyou!!
@johnthebest6819
@johnthebest6819 9 жыл бұрын
WOW . Thank you Very very very much . simple clear . i can't find more words .
@OddRandomThoughts
@OddRandomThoughts 9 жыл бұрын
Thank you +Julia A for the kind words. I'm glad you found it helpful!
@Mustafa_8D
@Mustafa_8D 2 жыл бұрын
hey bro thx lot you have helped me with my biggest problem
@rokfam
@rokfam 3 жыл бұрын
Thank you, Sir. It is exactly what I thought is possible: a simple solution. I wondered if the xtract would cause the new location system to error out or fail upon reboot if something is not compatible. One would need to restore between identical versions of the same OS I suppose? My plan is to backup my VPS and be assured I can take it over to another hosting service should the need ever arise. Is you method a sane solution to my use case or should I consider a different approach?
@harrisonpatrick3553
@harrisonpatrick3553 7 жыл бұрын
Thanks alot! very well explained. I'm currently in a trade for Microsystems and Networks, so this is really helpful! Thanks again :D
@Fawkes-ent
@Fawkes-ent 3 жыл бұрын
Great video would this backup databases and also settings for services I have made auto run thanks.
@stevenfrazier7959
@stevenfrazier7959 9 жыл бұрын
An excellent job, thanks for sharing. Really helpful.
@Seedlinux
@Seedlinux 9 жыл бұрын
Thanks as always ! Super simple tutorial and well done!
@Autamization
@Autamization 9 жыл бұрын
My Hero, Awesome video Thank You!
@DeepakKumar-xz2rp
@DeepakKumar-xz2rp 10 ай бұрын
thanks - very useful
@johnstowers4609
@johnstowers4609 9 жыл бұрын
Excellent job! Thank you very much!
@OddRandomThoughts
@OddRandomThoughts 9 жыл бұрын
+John Stowers You are quite welcome, thanks for watching!
@smallmoneybigmoney
@smallmoneybigmoney 5 жыл бұрын
Interesting. Does this keep file permissions and existing users?
@MrShivrajansingh
@MrShivrajansingh 4 жыл бұрын
Please tell how to exclude more than one directory
@vikassoundate4657
@vikassoundate4657 4 жыл бұрын
thanks man, that helped me. cheers!
@OddRandomThoughts
@OddRandomThoughts 2 жыл бұрын
You're welcome!
@juanjosecamacho6168
@juanjosecamacho6168 3 жыл бұрын
Thank you so so so much!!!!!!!!!
@OddRandomThoughts
@OddRandomThoughts 2 жыл бұрын
Glad it helped!
@aggrotic
@aggrotic 7 жыл бұрын
how do i have to do this to migrate from one vps to another server? I only get errors after rebooting :( there has to be an easy way to migrate the server (with all users/groups, configurations and files)
@LeonelProg
@LeonelProg 8 жыл бұрын
excelent! this backup the entire server? and i can restore a copy to another server? with sql database and all exactly like the original? like a clone server
@dewmguy
@dewmguy 5 жыл бұрын
Please answer this question @Odd Random Thoughts
@SM-bp3me
@SM-bp3me 4 жыл бұрын
Yes, just tried myself on ubuntu budgie. Thus i dont know how it would be if i restored on a system with an other desktop environment or s.th. what i did exactly was reinstalling the system from scratch and then extracting the backup.tar.gz like described in the video.
@applewinston
@applewinston 5 жыл бұрын
Thank for the video but can I Tar the root directory if the OS is running ? Will it having trouble tar the root directory if I am using tar command in the same linux OS to backup the whole system ?
@LithinThampan
@LithinThampan 6 жыл бұрын
Hi, great solution for backup and restore an entire server. Will this help to restore between VPS between different cloud service provider? For example AWS uses its own ubuntu distribution and Digital ocean uses its own distributions and what is the impact on network files and distribution files ? Thanks in advance
@navzme
@navzme 7 жыл бұрын
Good tutorial. Thank you very much.
@kankulivae648
@kankulivae648 2 жыл бұрын
would this work if i was going to install cpanel to my server? Sorry newbie. Im trying to do a reinstall cpanel on my server but need to back up content on my current root so that when I do a reinstall I can recover whats on my server now. Is that possible? What do you recommend me doing?
@britanniaonlineenglishscho1843
@britanniaonlineenglishscho1843 9 жыл бұрын
And if when I was creating a tarball of a full system backup (/ and /home in my case) I was using Ubuntu Live DVD and I haven't excluded anything from either / or /home, then when I will be restoring the system again with the Live DVD, is it a must to use --numeric-owner switch in the tar command?
@katrinafarmer6704
@katrinafarmer6704 8 ай бұрын
do u have a discord? once it gets to efi it halts with previous errors and just goes to grub only after reboot
@PurnenduSingh03
@PurnenduSingh03 8 жыл бұрын
Please I am also looking for the reply on @Perfect Prog question. Is it possible to restore backup to another system?
@fredneedle123
@fredneedle123 6 жыл бұрын
Can you use this method to restore your broken server to new metal?
@arunnarayanan9702
@arunnarayanan9702 6 жыл бұрын
Nice one, but i have some questions, can i take backup in server 1 and can i restore that in server 2 will it works?, if yes can i use the two different versions of Ubuntu, for example server 1 is 14.04 and server 2 is 16.04 will it works? my another question is can i access the backup files from my local Ubuntu machine? if yes can you please explain a bit? thank you !
@trustabyss
@trustabyss 2 жыл бұрын
This doesn't explain how to match the backup archive with the destination. If you installed software after the backup, the files will still remain. The only solution I've found is to boot into a live Linux distro, mount the local file system, delete every file under /, mount the drive containing backup, and restore the contents back into /. This is obviously not a good idea for SSD drives. Any suggestions on a better way of doing this?
@danobot12
@danobot12 9 жыл бұрын
What if you created new files between creating the back up and restoring it? You said unzipping the backup will overwrite all files. What about those files that were added in the meantime? They are junk after the backup is restored and they might interfere with the restored installation. How would you handle that?
@OddRandomThoughts
@OddRandomThoughts 9 жыл бұрын
+danobot Hi, just to clarify, any file created after the archive, will have no equivalent stored in the archive and thus will remain untouched. Therefore any new files you create will remain as they are, only files that are included in the backup would be overwritten. This would only be a problem if you were trying to restore onto a new installation on the same hardware, at which point only what was on the archive would be restored, that's why it's important to run a new backup when every you've made important changes or additions to your server. Hope this helps.
@danobot12
@danobot12 9 жыл бұрын
+Odd Random Thoughts yeah that makes sense. Kinda worried about forgotten junk files though. Do you reckon there's a way to diff the archive and the file system before restoring the backup to get rid of files that are not in the back up? (obviously excluding the directories that are not included in the backup like /dev)
@OddRandomThoughts
@OddRandomThoughts 9 жыл бұрын
+danobot Well what I would do if I wanted to restore the backup just as it was without including anything that had been added after it....Just do a clean install of ubuntu server and then extract the backup over that. That would eliminate any files that had been added after the backup had been created.
@Aref.nikandish
@Aref.nikandish 8 ай бұрын
very good
@GhostByteSoldier
@GhostByteSoldier 2 ай бұрын
damm 9 years ago does this still work
@harnam-chana
@harnam-chana 9 жыл бұрын
Nice! perfectly explained
@OddRandomThoughts
@OddRandomThoughts 9 жыл бұрын
***** Thanks for the kind words. I hope you found it helpful. :)
@js_programmer8423
@js_programmer8423 3 жыл бұрын
i did exactly what he told me to do..everything worked but when i logged out i was unable to log back in after the back up
@Lordblanca
@Lordblanca 4 жыл бұрын
Will this work on ubuntu server 18.04 as well or is there another command line for 18.04
@VinodKumar-ox6bg
@VinodKumar-ox6bg 6 жыл бұрын
after restore backup an other server ssh not login can you help ??
@applewinston
@applewinston 6 жыл бұрын
Is it possible to tar the whole root directory and restore it after formatting the OS?
@JackReacher1
@JackReacher1 2 жыл бұрын
wow what a champ
@NicolasHanna
@NicolasHanna 7 жыл бұрын
Big Help - good job
@VarDovoli
@VarDovoli 9 жыл бұрын
how would I add encryption to the backup and not lose any permissions or remove leading / from file names? nice video by the way.
@OddRandomThoughts
@OddRandomThoughts 9 жыл бұрын
Var D'ovoli when you're talking encrypting the backup you're envolving public/private key generation as well as creating a file with a passphrase etc. It can be somewhat overwhelming to the basic user. Not saying you are one of the basic users, but you may look into either openssl for creating your encryption or possibly symmetric encryption may be an option ie. tar -cz / | gpg -c -o backup.tgz.gpg the .gpg represents an encrypted archive. Hope this helps some.
@garretmartin2662
@garretmartin2662 2 жыл бұрын
Wish I knew this earlier
@Shuliyey
@Shuliyey 8 жыл бұрын
ty so much for this one ;)
@bangkokskater
@bangkokskater 8 жыл бұрын
hi, great tutorial, BUT I have this error during RESTORE ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
@bangkokskater
@bangkokskater 8 жыл бұрын
service mysql restart also could NOT work. [fail]
@RohitGupta-ki9tn
@RohitGupta-ki9tn 7 жыл бұрын
hello sir i m not able to restored backup
@RohitGupta-ki9tn
@RohitGupta-ki9tn 7 жыл бұрын
tar (child): /path/to/yourbackupfilename.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now
@DooryardGarage
@DooryardGarage 8 жыл бұрын
Does this still hold up with Ubuntu 16?
@OddRandomThoughts
@OddRandomThoughts 8 жыл бұрын
Hi, yes to the best of my knowledge this should still work the same if you're using Ubuntu 16. It wouldn't hurt anything to try it and see though if you have a freshly installed machine. Let me know how it turns out if you would. Thanks for watching! :)
@haidalejandroavilacarlon2110
@haidalejandroavilacarlon2110 9 жыл бұрын
Excellent!
@Jin33334
@Jin33334 9 жыл бұрын
easy and great
@aabaev
@aabaev 2 жыл бұрын
still actual 👍
@filipforex-o1r
@filipforex-o1r 6 жыл бұрын
Hi. when executing your command to backup my ubuntu server, at some point I got this: tar: /run/: file is on a different filesystem; not dumped /media/ /opt/ /sys/ tar: /sys/: file is on a different filesystem; not dumped What is it means?
@dimitrisarch8014
@dimitrisarch8014 5 жыл бұрын
Thanks!!!!
@NullifidianYT
@NullifidianYT 7 жыл бұрын
Thanks.
@Tali1562
@Tali1562 7 жыл бұрын
thanks!
@SonofaTech
@SonofaTech 6 жыл бұрын
bad ass
@ricko13
@ricko13 4 жыл бұрын
Too late :( I run the command: "sudo chmod 755 -R / " (YES, IN THE F*CKING ROOT directory)
@HarryoGaming
@HarryoGaming 8 жыл бұрын
Thanks very helpful! Like and from me subscribe.
@zl0y
@zl0y 9 жыл бұрын
У меня по Английскому двойка была(((
@ratfuk9340
@ratfuk9340 2 жыл бұрын
Awesome video, thank you.
@OddRandomThoughts
@OddRandomThoughts 2 жыл бұрын
Glad you liked it!
@KenpachiStarcraft
@KenpachiStarcraft 8 жыл бұрын
Thank you so much for this video!
@OddRandomThoughts
@OddRandomThoughts 8 жыл бұрын
You're very welcome!
@incog2678
@incog2678 3 ай бұрын
Thank you
@earnestredwood4694
@earnestredwood4694 7 жыл бұрын
Thank you...
Backup Strategies for Linux
32:24
DJ Ware
Рет қаралды 12 М.
Easy rsync Backup with tar and cron (daily, weekly, monthly)
22:14
Tony Teaches Tech
Рет қаралды 53 М.
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
ВЛОГ ДИАНА В ТУРЦИИ
1:31:22
Lady Diana VLOG
Рет қаралды 1,2 МЛН
Backup and Restore Your Linux System with rsync
12:10
Average Linux User
Рет қаралды 136 М.
How to Setup a Dedicated Home File Server Using Ubuntu Linux
22:19
Frank's Helpdesk
Рет қаралды 266 М.
Setting up Simple Samba File Shares
24:24
Learn Linux TV
Рет қаралды 263 М.
How to Build Your Own E Mail Server using Ubuntu Server 14.04
1:08:34
Odd Random Thoughts
Рет қаралды 123 М.
18 Commands That Will Change The Way You Use Linux Forever
29:50
Akamai Developer
Рет қаралды 1,3 МЛН
What's the BEST home server operating system?
17:35
Christian Lempa
Рет қаралды 735 М.
Backup MySQL or MariaDB
16:46
WiseCat
Рет қаралды 2,9 М.
Linux Backup with TAR and Cron Jobs
35:33
Eli the Computer Guy
Рет қаралды 250 М.
Creating Incremental Backups with Tar
11:17
theurbanpenguin
Рет қаралды 10 М.
JISOO - ‘꽃(FLOWER)’ M/V
3:05
BLACKPINK
Рет қаралды 137 МЛН