LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-23-2021, 11:59 AM   #1
mc510
LQ Newbie
 
Registered: Aug 2009
Distribution: Armbian, ChromeOS
Posts: 14

Rep: Reputation: 1
Properly creating a system backup with tar?


Lot of guides focus on how to backup user data, but I'm interested in backing up the current state of my Debian Buster system. Why? Because I've had a few experiences of breaking something or other on my system with an ill-advised install or update, and as a Linux newbie I don't know how to fix it so would like to have a backup of the system that I can just restore.

Does it make sense to use tar for this? I see discussion about directories (and files) that shouldn't be backed-up and restored, but different things in different discussions so my head is kind of spinning. Can anyone suggest a tar command to backup the system in a way that would allow it to be easily restored?
 
Old 07-23-2021, 01:47 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,662

Rep: Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710
Tar is a wonderful tool for creating an archive (Tape ARchive: it should be) but it is not directly a backup program. It can be used as one part or piece of a backup system or strategy, but it is certainly not a snapshot tool.

I have written systems for the purpose, but it requires knowing EXACTLY where every critical configuration file in your system lives and what applications read that configuration. And even then doing it manually can miss something.

It is easier to do this with BTFS snapshots, but then your entire system must be BTRFS based.

Timeshift is one tool specifically intended for this purpose. This is the kind of solution I would recommend. Using it you can "roll back" recent changes if things go south on you.
 
1 members found this post helpful.
Old 07-23-2021, 02:00 PM   #3
mc510
LQ Newbie
 
Registered: Aug 2009
Distribution: Armbian, ChromeOS
Posts: 14

Original Poster
Rep: Reputation: 1
Thanks, I appreciate that advice. I did come across Timeshift and thought it looked intriguing, but I haven't been able to find any guides to using it on a headless server. It's probably possible, right?
 
Old 07-23-2021, 02:25 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Here is a timeshift command line guide: https://dev.to/rahedmir/how-to-use-t...-in-linux-1l9b. Note: A proper backup is stored apart from the storage medium that you back up, otherwise it doesn't protect against media failure.
 
2 members found this post helpful.
Old 07-23-2021, 03:25 PM   #5
mc510
LQ Newbie
 
Registered: Aug 2009
Distribution: Armbian, ChromeOS
Posts: 14

Original Poster
Rep: Reputation: 1
Yeah, that was the one that I found too. Unfortunately it doesn't say anything about how to configure timeshift from the command line, but maybe I can figure that out from the documentation.
 
Old 07-23-2021, 06:42 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,993

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
"current state of my Debian Buster system."
To me that seems like an offline clone or some live state clone.

Plenty of online tutorials for timeshift.
https://dev.to/rahedmir/how-to-use-t...-in-linux-1l9b
https://itsfoss.com/backup-restore-linux-timeshift/

Last edited by jefro; 07-23-2021 at 06:44 PM.
 
Old 07-23-2021, 06:43 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
If it's headless, that to me says no desktop environment (GUI). What's the point of using a GUI wrapper for rsync ?.

rsync is your friend - maybe have a look at something like rsnapshot for scheduled backups.
 
Old 07-23-2021, 08:02 PM   #8
obobskivich
Member
 
Registered: Jun 2020
Posts: 596

Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
If it's headless, that to me says no desktop environment (GUI). What's the point of using a GUI wrapper for rsync ?.

rsync is your friend - maybe have a look at something like rsnapshot for scheduled backups.
This, or (assuming you have 'unlimited hardware resources and time') just clone the system drive(s) to something equivalent and if it 'goes bad' swap to the other drive. This would require some physical intervention and take a lot of time depending on how much data we're talking about. You should be able to do this with dd or get a standalone 'disk cloner' machine (they cost about $30 and usually double as external hard drive docks). Crude but effective. In a GUI, GNOME Disks can create snapshots as well (and it doesn't just run in GNOME), but if you're headless that may not work.
 
Old 07-24-2021, 07:03 PM   #9
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by wpeckham View Post
Tar is a wonderful tool for creating an archive (Tape ARchive: it should be) but it is not directly a backup program. It can be used as one part or piece of a backup system or strategy, but it is certainly not a snapshot tool.

I have written systems for the purpose, but it requires knowing EXACTLY where every critical configuration file in your system lives and what applications read that configuration. And even then doing it manually can miss something.

It is easier to do this with BTFS snapshots, but then your entire system must be BTRFS based.

Timeshift is one tool specifically intended for this purpose. This is the kind of solution I would recommend. Using it you can "roll back" recent changes if things go south on you.
Tar was designed to do backups and works very well at the task. Where some go wrong in using it is they fail to make sure the data being archived is static. If a file changes during the backup then corruption can occur. In other words, a tar of an entire OS has to be done by booting from something like a live usb and then running tar on the OS. By using the proper parameters you can archive everything, only a particular directory tree, or even limit the tar file to data on a single partition. Man tar gives you a lot of info on the options avialable, and it for quite some time now even is able to create a compressed tar file and extract same.

I do not understand your statement that tar is not a good archive tool since it is one of the best and has been around since the early days of computers. If it were not capable of the tasks it would have been retired long ago. Certainly there are a lot of others that do backups differently but the old standbys are still very much alive and functional.

A simple and effective way to use tar for backing up any single directory tree, including /, is "tar cvf /path/to/arcive/file.tgz /path/to/directory". this will create the tar file in the directory where you specify and copy all the data in the absolute path given. The tar file will be gzipped as well. Note that the normal permissions rules apply, and the user has to have read access to the data being tarred up.

Read the man page to see what cvf does and also what other options you may wish to use.

Last edited by computersavvy; 07-24-2021 at 07:19 PM.
 
Old 07-24-2021, 07:09 PM   #10
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,662

Rep: Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710
Thumbs down

Quote:
Originally Posted by computersavvy View Post
Tar was designed to do backups and works very well at the task. Where some go wrong in using it is they fail to make sure the data being archived is static. In other words, a tar of an entire OS has to be done by booting from something like a live usb and then running tar on the OS. By using the proper parameters you can archive everything, only a particular directory tree, or even limit the tar file to data on a single partition. Man tar gives you a lot of info on the options avialable, and it for quite some time now even is able to create a compressed tar file and extract same.

I do not understand your statement that tar is not a good archive tool since it is one of the best and has been around since the early days of computers. If it were not capable of the tasks it would have been replaced long ago. Certainly there are a lot of others that do backups differently but the old standbys are still very much alive and functional.
RE-read my post. I did not say "tar is not an archive tool", I said "...Tar is a wonderful archive tool ...". I said it is "not directly a backup program". and stand by that.

Real backup programs allow for generational backups and restore to point in time. Some provide (critical to this users question) snapshot and rollback. There are other tools that provide snapshot and rollback, but TAR is not one of them. He need something that will quickly take a snapshot, and allow him to roll it back if an install or update goes south on him. TAR is a great tool, but it is not THAT tool.
 
Old 07-25-2021, 12:47 PM   #11
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
When written tar was the only and an excellent backup tool. Users needs have changed dramatically since, and as you say there are a lot of newer and better tools for snap shots and incremental backups that are now available.

To the OP
Tar is a wonderful tool for static backups, but is not designed for and does not work well for incremental snapshots/backups. It has no concept of changes, only copies everything there at the moment it is run. As suggested above there are better tools for doing any form of backup that is not a "copy everything" while static.

Tar can do updates of files already in the archive, but is not the best for that.
 
Old 07-26-2021, 10:57 AM   #12
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,662

Rep: Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710
For a single-tool backup of your entire system, so it will boot the old version perfectly, you might look into clonezilla. IT gets all parts of the storage, including the parts that do not mount and that TAR cannot even see.
 
Old 07-27-2021, 08:48 PM   #13
mc510
LQ Newbie
 
Registered: Aug 2009
Distribution: Armbian, ChromeOS
Posts: 14

Original Poster
Rep: Reputation: 1
Well, I was excited about TimeShift, but the docs say that it works only with GRUB2, and my Orange Pi uses U-Boot. I guess I'll check out rsnapshot, clonezilla, and other tools that backup the entire drive (or partition?) rather than just the system.
 
Old 07-27-2021, 09:58 PM   #14
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,993

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
http://www.orangepi.org/orangepibbse...hread&tid=4296

Use some command line from some minimal pxe image I'd think. rsync, tar, cpio ...
 
Old 07-28-2021, 10:40 AM   #15
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,662

Rep: Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710Reputation: 2710
I am working now on a Pinebook Pro. If I want a snapshot of the system, I just do a dd of the entire internal storage device to a fast SD card. If I need to go back, I can boot form the SD card and DD the image back onto the internal storage (or just run from the SD card for a few days). I see no reason something like that would not work for your RPi.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
Tar fails on system backup - need to backup remote web server cilbuper Linux - General 2 08-26-2014 12:28 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
How do I un tar a .tar, .tar.z, .tar.gz file vofkid Linux - Newbie 4 03-15-2002 02:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration