LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-05-2024, 01:25 AM   #1
JASlinux
Member
 
Registered: Oct 2020
Posts: 380

Rep: Reputation: Disabled
Should tar be used for partition backup?


The examples I see are for folder/files or the entire system from /.

I do not see why not, but I cannot determine whether to archive from /dev or the mount point.

dd is giving me errors so I am seeking alternatives.
 
Old 01-05-2024, 01:39 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,879

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
you must not archive /dev. I mean never ever. You always need to use the mount point. Otherwise would be nice to know what are you trying to achieve again, what errors did you get...
(ok, there can be some exceptions when you want to access /dev/something, but in that case you need to know exactly what are you doing).

Last edited by pan64; 01-05-2024 at 01:40 AM.
 
Old 01-05-2024, 08:32 AM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,987

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
Backing up a running system can be problematic. Best to use a livecd, mount the partition you want to backup, cd to that partition mount point and run:

Code:
$ sudo tar --acls -czvpf /<path to backup location>/backupfile.tar.gz .
Note, always use tar as root or use sudo for this backup. Some files are readonly by root and will be missed in your backup(permission denied) if you do not have admin privileges. Also note the "--acls" flag. Most modern linux distros use acl permissions for some purposes. Without this flag, tar will not pick up those acl permissions. Most modern distros have a recent enough version of tar that can handle acl permissions if you use the "--acls" flag. Note also the trailing period at the end of the above line of code. That tells tar to archive the current directory and needs to be there.

To restore from such a backup, again, use a livcd, mount the partition you want to restore, delete all the contents of the partition, cd to the partition mount point and run:

Code:
$ sudo tar --acls -xzvpf <path to backup file>
Note, do not reformat the partition instead of deleting the files as reformatting will change the uuid of the partition messing up your fstab and grub.
 
2 members found this post helpful.
Old 01-05-2024, 01:00 PM   #4
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,499

Rep: Reputation: Disabled
Take a look at rsync - https://linux.die.net/man/1/rsync
 
Old 01-05-2024, 01:08 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,991

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
If you want to back up a root or system partition then don't unless you are using a live state backup. I think fsarchiver does it live state. As above a few issues.

A data only partition is what tar or some gzip sort of deal is for.

If you want to make an image of the working partition then boot to some live media maybe.
 
Old 01-05-2024, 02:03 PM   #6
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by JASlinux View Post

Should tar be used for partition backup?

A backup system based on rsync is far superior to tar backups or dd backups. If you create a backup system based on tar or dd be sure to run some restore tests for a bare metal restore, restoring a previous version of a single file, and restoring a file that was deleted a few days before the current backup was run.

No matter what backup system you create you don't need to backup /sys or /dev because you will never restore them.

Last edited by jailbait; 01-05-2024 at 02:05 PM.
 
Old 01-05-2024, 02:50 PM   #7
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,647

Rep: Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697
#1 Rsync is not backup software, it is an application for file and folder syncronization.
#2 Tar makes Tape ARchives, and is not backup software. Tar can be used to archive files and folders.
#3 A tool that can sync or archive files and folders can be a useful, even critical, PART of a backup and recovery plan or strategy.
----
If what you want to back up is a partition, then what you need is a tool that creates an archive, copy, or clone of a partition: not just files or folders!

I have used mirroring for backups: make and sync a mirror, break the mirror, and archive with compression the idle and going stale copy of the mirror. That was like magic to remove downtime during backups while ensuring they were consistent back in the day: I no longer recommend that. We have smarter tools now.

For your purposes a true backup tool would be preferred, and if you want partition backups then a tool specific to partitions might serve best. PArtimage and clonezilla come to mind at once.
 
Old 01-05-2024, 08:29 PM   #8
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I use lvm snapshots via script. Create snapshot, tar snapshot to external drive. remove snapshot when done. automatic. That + timeshift hourly and I've nary an issue.
 
Old 01-15-2024, 11:57 PM   #9
JASlinux
Member
 
Registered: Oct 2020
Posts: 380

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
#1 Rsync is not backup software, it is an application for file and folder syncronization.
#2 Tar makes Tape ARchives, and is not backup software. Tar can be used to archive files and folders.
#3 A tool that can sync or archive files and folders can be a useful, even critical, PART of a backup and recovery plan or strategy.
----
PArtimage and clonezilla come to mind at once.
Reading through replies I have not commented because I have a lot to learn.

The need for byte-for-byte backup is something that has always perplexed me, as source & destination are rarely equivalent media & motivate circumspection. I notice in Linux problems with symlinks but at least we don't have hidden system files to worry about like Redmond (the difference between copying & a real 'backup').

I confess only tinkering with dd while relying Windows builtin backup & AOMEI Backupper. If I could do the same thing in Linux I would.
 
Old 01-16-2024, 10:56 AM   #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,647

Rep: Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697Reputation: 2697
Virtually every Linux distribution that has a repo system has backup and imaging tools in the repo: those are the backup and recovery and imaging tools native to Linux. Perhaps searching your repo will provide you some places to start your research, and all of the tools you need for your purpose.
 
1 members found this post helpful.
  


Reply

Tags
backup, partition, tar



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 On
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
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 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 - General

All times are GMT -5. The time now is 06:52 PM.

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