How to backup root file system, /, w/o copying /dev, /proc

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

How to backup root file system, /, w/o copying /dev, /proc

Postby hankivy » Jun 16th, '21, 06:31

I would like advice. As part of upgrading to Mandriva 8, I should backup all of my files.
Adding an empty 1 TB stand-alone disk mounted on /media/BKP, an simple approach would be a command like:
Code: Select all
sudo cp -a /* /media/BKP/.

But I don't want to copy files such as /dev/*, /proc/*, or /media/* for obvious reasons.

:?: What is the simplest way to do a full backup without these unneeded files? :?:

Thank you.
hankivy
 
Posts: 119
Joined: May 19th, '14, 20:36

Re: How to backup root file system, /, w/o copying /dev, /pr

Postby doktor5000 » Jun 16th, '21, 17:09

Instead of blindly copying "all your files" it's probably easier to check where the files are, that you care about.

Usually those should be restricted to /home, maybe /etc and otherwise they should be on separate filesystems. So it might make more sense to only selectively back that up,
instead of going for a backup where you need to list everything that should be excluded - which is quite a lot more from what you listed, as you need to exclude everything.

Easiest way would probably to use rsync with something like
Code: Select all
rsync -a / /media/BKP/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/boot/*,/var/tmp/*,/var/cache/*,/usr/tmp/*,/media/BKP/*}

For some more pointers, maybe have a look at e.g. viewtopic.php?f=41&t=5957
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 16793
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How to backup root file system, /, w/o copying /dev, /pr

Postby jiml8 » Jun 17th, '21, 20:17

jiml8
 
Posts: 1188
Joined: Jul 7th, '13, 18:09

Re: How to backup root file system, /, w/o copying /dev, /pr

Postby hankivy » Jun 19th, '21, 07:46

In the following I list the root folder, and all of my file systems.
Then I raise issues with links, both hard and symbolic.
Then I ask for more specific advice.

Code: Select all
$ (ls -al / ; df)
total 172
drwxr-xr-x  22 root root  4096 Mar 18 15:48 ./
drwxr-xr-x  22 root root  4096 Mar 18 15:48 ../
lrwxrwxrwx   1 root root     7 Sep 24  2018 bin -> usr/bin/
drwxr-xr-x   5 root root 12288 Jun 15 22:56 boot/
drwx------   2 root root  4096 Mar 18 15:48 .cache/
drwx------   3 root root  4096 Dec 16  2019 .dbus/
-rw-------   1 root root 66577 Dec 23  2019 dead.letter
drwxr-xr-x  21 root root  4540 Jun 15 22:56 dev/
drwxr-xr-x 139 root root 12288 Jun 15 22:57 etc/
drwxr-xr-x  12 root root  4096 Sep 24  2018 home/
drwxr-xr-x   2 root root  4096 Sep 24  2018 initrd/
lrwxrwxrwx   1 root root     7 Sep 24  2018 lib -> usr/lib/
lrwxrwxrwx   1 root root     9 Sep 24  2018 lib64 -> usr/lib64/
drwx------   2 root root 16384 Dec 16  2019 lost+found/
drwxr-xr-x   2 root root  4096 Sep 24  2018 media/
drwxr-xr-x   2 root root  4096 Sep 24  2018 mnt/
drwxr-xr-x   4 root root  4096 Dec 21  2019 opt/
dr-xr-xr-x 310 root root     0 Jun 14 14:40 proc/
drwxr-x---  12 root root  4096 Jun 18 12:30 root/
drwxr-xr-x  36 root root  1000 Jun 18 12:01 run/
lrwxrwxrwx   1 root root     8 Sep 24  2018 sbin -> usr/sbin/
drwxr-xr-x  11 root root  4096 Nov 28  2020 share/
drwxr-xr-x   2 root root  4096 Sep 24  2018 srv/
dr-xr-xr-x  13 root root     0 Jun 14 14:40 sys/
drwxrwxrwt  15 root root  4096 Jun 18 04:02 tmp/
drwxr-xr-x  14 root root  4096 Dec 16  2019 usr/
drwxr-xr-x  19 root root  4096 Jul  4  2020 var/

Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        1.9G     0  1.9G   0% /dev           *
tmpfs           1.9G   50M  1.9G   3% /dev/shm       *
tmpfs           1.9G  1.2M  1.9G   1% /run
/dev/md0         39G   84M   37G   1% /
/dev/md1         44G   38G  4.6G  90% /usr
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/md127      7.7G  711M  6.6G  10% /boot
/dev/md2         43G   53M   40G   1% /tmp
/dev/md3         41G   17G   22G  43% /var
/dev/md4        192G   82G  111G  43% /home
/dev/md5        544G  112G  405G  22% /share
tmpfs           384M   48K  384M   1% /run/user/1000


issues with links:

Hard Links: The inode numbers used in hard links are only unique to each file system. For example, I am backing up files from file systems (/, /usr, /var, /home, and /share). If I copy hard links as another hard link, (and do not copy each entire data file) then I need to have a separate destination file system for each of the source file systems.

Symbolic Links: Symbolic links come as absolute, and relative links.
Looking above "bin -> usr/bin" is a relative link. "bin -> /usr/bin" would be an absolute link. A copy of a relative link still points to the original file in the destination file system. A copy of an absolute symbolic link points to the file in the source file system, which may have changed.

If the above is correct then the backup destination must have separate file systems for each of the source file systems.

The sample code in viewtopic.php?f=41&t=5957 excludes (/dev, /tmp, /var/tmp, /var/cache, /home, /media, /proc, /sys, and /mnt). He uses other means to backup /home.

Should I exclude /run? :?: How should I deal with the lost+found folders? :?:
Last edited by doktor5000 on Jun 19th, '21, 11:00, edited 1 time in total.
Reason: added code tags
hankivy
 
Posts: 119
Joined: May 19th, '14, 20:36

Re: How to backup root file system, /, w/o copying /dev, /pr

Postby hankivy » Jun 19th, '21, 07:47

Thank you to everyone who offered help. :D
hankivy
 
Posts: 119
Joined: May 19th, '14, 20:36

Re: How to backup root file system, /, w/o copying /dev, /pr

Postby isadora » Jun 19th, '21, 09:48

Please, don't forget to mark the topic [SOLVED].
You can do so, by editing the subject/title in the first message in this topic.
Write [SOLVED] to the left of subject/title, thanks ahead. ;)
..........bird from paradise..........

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry
User avatar
isadora
 
Posts: 2686
Joined: Mar 25th, '11, 16:03
Location: Amsterdam, the Netherlands


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest

cron