LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Should tar be used for partition backup? (https://www.linuxquestions.org/questions/linux-general-1/should-tar-be-used-for-partition-backup-4175732463/)

JASlinux 01-05-2024 01:25 AM

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.

pan64 01-05-2024 01:39 AM

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).

kilgoretrout 01-05-2024 08:32 AM

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.

fatmac 01-05-2024 01:00 PM

Take a look at rsync - https://linux.die.net/man/1/rsync

jefro 01-05-2024 01:08 PM

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.

jailbait 01-05-2024 02:03 PM

Quote:

Originally Posted by JASlinux (Post 6474729)

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.

wpeckham 01-05-2024 02:50 PM

#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.

jmgibson1981 01-05-2024 08:29 PM

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.

JASlinux 01-15-2024 11:57 PM

Quote:

Originally Posted by wpeckham (Post 6474840)
#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.

wpeckham 01-16-2024 10:56 AM

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.


All times are GMT -5. The time now is 04:28 PM.