LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 01-06-2024, 05:50 PM   #1
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195
Blog Entries: 2

Rep: Reputation: 5
Question How to full backup and restore only filled Ubuntu desktop?


Hello. I have an Ubuntu 22.04.3 desktop with Ubuntu Pro Lenovo Thinkpad T460 and would like a full backup that only holds filled space that I can do a full restore from. I have tried partition image for like my Ubuntu partition and that tries to make an image with all space including empty space. That is impractical for me. I have figured a way to have all timestamps recorded with a script. With that I could use rsync and an ext4 USB to back up like fully if not fully. It would be from / to USB and I mostly know how to do from computer to USB. Like my problem comes about by group and owner of USB and how do I get all, as in no thing excluded, things back to like my computer. I do not know if I could access all including root directories. I think I can but am unsure.

With that I am also unsure if rsync would overwrite like my USB restoring unless I do not specify --delete and that could leave mass of unwanted files. I could rsync from a bootable USB and have both computer and USB separate allowing easy transfer except I do not know if I can access all files on that USB from a bootable USB. Like my bootable USB is an Ubuntu 22.04.2 desktop USB.

I could also copy as nobody/nogroup to that USB and should be able to access all files on that USB with a bootable USB with that. Like my problem with that occurs with resetting group/owner. I can store group/owner as a file but would I be able to set it again? I guess like my main question in this is if as like owner and group of nobody no group stuff if I can set group and owner on a bootable USB.

I have set forth three possible methods of full backup that would be acceptable to me if I could resolve at least one problem with each. All backup tools I know of leave out something like created at timestamps or something so I am trying to make like my own backup and restore solution. backing up is not like my problem, it is restoring. Can anyone help with this? I would probably use an ext4 USB.

For testing of whether I could use these here are like my solutions. For root access on USB, try to do sudo rsync on a bootable USB with source a root owned/grouped folder. You can use sudo touch to make that folder. A thing probably not to try but a test, on a blank install, rsync All to a USB then re-rsync back all stuff no bootable USB. For last with nobody/no group, make a nobody/no group thing at root or any public to All place and use numeric ID to set owner/group to your user or root. Any one of these tests would maybe allow or show I cannot make a full backup this way. I am leaning toward nobody/no group backup as even a Windows reader could access that. All as per one might be maybe or might not be maybe, maybe or maybe not, maybe.

Last edited by maybeJosiah; 01-07-2024 at 11:43 AM. Reason: Test solutions maybe
 
Old 01-07-2024, 02:22 PM   #2
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
I'm not sure about USB, but it would probably work in a similar fashion. I have, for years, done my back ups by mirroring (using rsync from a portable Linux - Porteus) onto a secondary hard drive on my system specifically set up and partitioned exactly as my primary drive is. It's quite easy to rsync a backup onto the secondary drive and then, if necessary, rsync it back to the primary drive as a "recovery" method. In a pinch, after making the secondary drive bootable, I can also just boot to the backup directly.

Like I said at the start, though, not sure about USB. I've never tried to do it that way. I don't see why it wouldn't work, though.
 
Old 01-07-2024, 02:38 PM   #3
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
Unhappy

Quote:
Originally Posted by vtel57 View Post
I'm not sure about USB, but it would probably work in a similar fashion. I have, for years, done my back ups by mirroring (using rsync from a portable Linux - Porteus) onto a secondary hard drive on my system specifically set up and partitioned exactly as my primary drive is. It's quite easy to rsync a backup onto the secondary drive and then, if necessary, rsync it back to the primary drive as a "recovery" method. In a pinch, after making the secondary drive bootable, I can also just boot to the backup directly.

Like I said at the start, though, not sure about USB. I've never tried to do it that way. I don't see why it wouldn't work, though.
Hey, rsync on Linux desktop does not currently support -N, --crtime, created at, and you said you rsync it back to original drive, how? Why it would not work is with --delete it deletes all not on origin and I can't have USB contain like my USB and without --delete I am left with system files that maybe should not be. I have reason to believe this won't work on USB and I am trying for an external backup but thanks. USB is located in root but in your case there are two roots. All as per one might be maybe or might not be maybe, maybe or maybe not, maybe.
 
Old 01-07-2024, 02:44 PM   #4
rclark
Member
 
Registered: Jul 2008
Location: Montana USA
Distribution: KUbuntu, Fedora (KDE), PI OS
Posts: 487

Rep: Reputation: 180Reputation: 180
I backup to USB portable drives all the time. Just format the drives with ext4 (obviously you only do this once) before you backup with rsync and all timestamps, groups, etc. are preserved. Using the --delete option keeps your backup 'synced'. Easy Peasy. Now I don't backup up the whole 'system' I only backup 'data'. The OS is 'easy' to re-install and setup again. Also this gives you a clean system again. So for my clients I just backup up the /home folder and any special files like VMs if not located under /home. Simple. My home server I just backup all the data folders. YMMV of course. Works for me.

Last edited by rclark; 01-07-2024 at 02:47 PM.
 
Old 01-07-2024, 02:47 PM   #5
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
Unhappy

rclark, again, that won't work for a backup of root as USB is like in root maybe or maybe not, maybe.
 
Old 01-07-2024, 03:40 PM   #6
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
I back to only USB drives and have done so for years. You solve the ownership problems by backing up as root and telling rsync to preserve ownership and permissions. My backup routine is very similar to the one described by rclark with the exception that I also backup the entire OS except for /dev and /sys.
 
1 members found this post helpful.
Old 01-07-2024, 03:48 PM   #7
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
Lightbulb Solution?

I think I found a solution nearly. Just rsync in all corresponding folders with --delete and stuff except /mnt, then rsync without ~-delete /mnt, then similar process excuding /mnt/usb without that without --delete rsync and repeat in /mnt/usb that second phase. Like my only question is whether I can rsync in all files and folders including root and other than like my user stuff from an installed system. Also, all folders should end in /. It seems I can but am I wrong in anything saying I can? Also, I may copy as nobody/nogroup and set user/group on USB when needed to restore. One question I have about that is whether I lose anything else other than usee/group. Maybe one with user/group already. rsync does not seem to have copy to exclude deleting and copy to. Reason I would like nobody/nogroup is for Windows ext4 reader access. All as per one might be maybe or might not be maybe, maybe or maybe not, maybe.

Last edited by maybeJosiah; 01-07-2024 at 03:50 PM. Reason: Advance?
 
Old 01-07-2024, 06:21 PM   #8
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
> you said you rsync it back to original drive, how?

Same way I rsync'd it to the secondary drive in the first place. Oh, and to be more accurate, I actually use grsync in Porteus (portable Linux on CD/DVD) to do this backing up. You cannot rsync a partition that is in use because of the journaling that's constantly writing to the drive while it's mounted.

Also, Clonezilla will serve the same purpose and may be easier for folks to use as a backup tool than rsync/grsync. If you use rycnc/grsync BE SURE to remember to put the following / after your source drive or else you will end up with a raw data sync in its own directory rather than a true copy of the partition you're attempting to back up.

So, for instance:

Source: /mnt/sda1/
Destination: /mnt/sdb1

This will mirror your No.1 partition on your No.1 drive to the No.1 partition on the No.2 drive on your system. To go the other direction, just change your source/destination drives/partitions:

Source: /mnt/sdb1/
Destination: /mnt/sda1

____

Helpful links:

Porteus Portable Linux

Grsync – A Simple Graphical Frontend For Rsync

Clonezilla

A Good Clonezilla Tutorial
 
Old 01-07-2024, 06:38 PM   #9
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
Question More questions maybe

Thanks vtel57 for that do not sync while in use. I actually got to /media/USB/my USB last time so I think I can rsync on a mounted disk maybe but not trying unless I must. I can still use sudo on a bootable USB to get at root stuff, correct? I think that can be done and can test it like myself, may post result. I prefer a files and folders backup so I can be sure all is backed up. Just for whether I use Clonezilla or not, does it restore created at when you restore? All as per one might be maybe or might not be maybe, maybe or maybe not, maybe.
 
Old 01-07-2024, 07:11 PM   #10
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
A true rsync backup is identical to your original (at the time you backed it up, of course). If you restore it, your user and root will still function identically to the primary version you copied originally. Rsync is basically a bit-by-bit copy of all the data on that partition you're backing up.

If you're backing up to a USB drive as "data" (not a bootable partition), I'm pretty sure your data will be accessible to you as root/sudo. Like I said, though, I've never tried it on a USB. I've always used mirrored drives for my backups. Now when I just plain ol' copy data, like my /etc directory, to a CD/DVD back up, I can definitely still access it as root once I've mounted the CD/DVD, so I wouldn't think USB drive would not be any different... just mount and access/copy.

Clonezilla creates an identical copy of a partition, just like rsync. If you had a Clonezilla copy of your File System and /home directories on a secondary hard drive, you could boot them and start your OS just as you do your primary hard drive.

By the way, plain ol' coping of directories from your running system to backup media like USB drives or CD/DVD works well, too. However, it's not a complete recovery type backup. If your main drive failed and you installed a new drive, that data you backed up on your USB drives or CD/DVDs would come in handy, but they would still require you to install a fresh installation of your operating system onto your new replacement drive. With a true rsync'd or mirrored/cloned drive image, you could restore that to your newly installed hard drive and it would boot JUST LIKE the system you had installed on the defective hard drive. See the diff?

Anyway, fun stuff. Back up any way you can and try to stick to your regular backup schedules. It's a wonderful thing to have backups, believe me!
 
Old 01-07-2024, 07:53 PM   #11
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
Question One question left maybe

One concern I have with rsync is that mine does not support -N, created at times, and like mine is latest version. Created at time is important to me and rsync on like my desktop is not fully up for that. Clonezilla I was hoping could set created at timestamps but since that is not a commonly known how to do thing, unsure. All I ever found for that was debugfs, not for "regular use".

Like my problem now that you told me about it is: can I run sudo on like my main machine drive from a bootable USB? That seems to be only question left to answer. One work around I know of is set sudoers to all with no password. That can be done on any ext4 including USB. I can test like my one problem now on like my computer but feel free to answer it. I do not like using live USB, dangerous stuff.

I have a timestamps and group and owner recorder program and restore program if it helps. That I can run while mounted and in use. It records all as in none left unrecorded. Anyway, ome question now and I can probably answer it like myself. All as per one might be maybe or might not be maybe, maybe or maybe not, maybe.
 
Old 01-07-2024, 08:12 PM   #12
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
The rsync flags I use to do a backup of the currently running OS system look like this:

Code:
rsync -vaxAX --delete /. /mnt/sda1/RamBak/
This saves everything stored inside the root partition's file system. It does NOT save the partition info (such as its UUID) or the MBR bootloader because those things are not stored inside the root partition's file system.

Note that these flags specify to ONLY backup files within a single file system. In other words, it doesn't save any files within mounted file systems, just the folder of the mount point. In my experience, this is pretty much 100% of the time the thing you want to do.

In some cases, the root partition is huge and I want to back up the big main data and the OS separately. In that case, I create a directory called /Mo/ and I put the big main data inside /Mo. My OS backup would then be:

Code:
rsync -vaxAX --delete /???* /mnt/sda1/RamBack/
This way, the backup will skip /Mo because 'Mo' is only two letters long. All of the normal OS stuff in root is named 3+ letters long.

I have restored from these backups and they 100% work fine. The "axAX" flags replicate all the necessary file permissions and flags.

In fact, if you look at my blog post on "RamBoot", you'll see a technique I use which restores from this backup every single boot. The basic idea is to use rsync to maintain a backup to a directory called "RamBack". Upon boot, a small bit of custom boot code creates a tmpfs ram drive and mounts that ram drive to "/". Oops, this ram drive starts of EMPTY! But the custom boot code restores the contents from the RamBack folder before continuing the boot process.

My point is, I HEAVILY save and restore from these backups, so I really know these flags work.
 
1 members found this post helpful.
Old 01-07-2024, 08:39 PM   #13
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195

Original Poster
Blog Entries: 2

Rep: Reputation: 5
So just to be clear, you did that on a bootable USB and did restore on a bootable USB back to main storage? If not then how? "RamBack" blog read and did not help maybe or maybe not, maybe.

Last edited by maybeJosiah; 01-07-2024 at 08:49 PM. Reason: RamBack maybe
 
Old 01-07-2024, 08:50 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,740

Rep: Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923
As far as I know the rsync --crtimes -N option is only valid for Mac OS at the moment. linux does not support crtimes in general yet. Birth time was just added as s file stat not that long ago (around 5.11 kernel version) As you posted debugfs can be used to set crtimes but really not a good option and not on a mounted filesystem.
 
Old 01-07-2024, 08:53 PM   #15
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by maybeJosiah View Post
So just to be clear, you did that on a bootable USB and did restore on a bootable USB back to main storage? If not then how?
I've done it with a bootable USB, but damn it was so slow (at the time, I only had USB2.0). There is no difference in either direction, other than the slowness.

But yes, I've used rsync heavily for replicating bootable USB and saving/restoring. The big problem with some other techniques is all the wasted time on empty space. Also, I find it convenient that I can interrupt an rsync process and then continue later on. For example, let's say I start a restore but I forgot I wanted to alter /etc/fstab first. I can stop the rsync, edit /etc/fstab, and then start up a new rsync without losing the progress so far. USB2.0 is so slow that this is real nice quality-of-life stuff.

Note that I have been using this with only ext2, ext3, ext4, and btrfs - all Linux file systems, which is necessary to ensure all of the file permissions and attributes can be replicated 100%.

I have also used rsync with NTFS and FAT32 for data backups, but these require a "time window" option to deal with their different time resolution, and of course file permissions/attributes aren't carried over.

Anyway, Linux quintessentially treats USB drives exactly the same as internal drives. The only difference is (lack of) performance.
 
  


Reply

Tags
backup, restore, ubuntu, usb



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
LXer: Ubuntu 20.10 goes full Raspberry Pi, from desktop to micro clouds: Full fat desktop on a Pi is usable LXer Syndicated Linux News 0 10-23-2020 11:17 PM
tar: restore only non-hidden files during a restore of /home Alan_ Linux - Newbie 4 05-25-2014 06:10 PM
[SOLVED] Hard drive partitioning, backup and restore full disk images Tem2 Linux - Newbie 36 01-17-2012 08:33 AM
backup the RHEL5 server with Cpanel and create full system restore disk zaki Linux - Newbie 1 08-31-2009 11:59 AM
HELP: rysnc filled my partition during backup. PhilK Linux - Newbie 1 08-03-2007 04:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 12:54 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