Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Comparing backup scripts
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Astronome
Tux's lil' helper
Tux's lil' helper


Joined: 02 Jan 2016
Posts: 148

PostPosted: Sun Feb 14, 2016 12:33 am    Post subject: [Solved] Comparing backup scripts Reply with quote

I'm comparing these two backup scripts:

https://github.com/gsra99/mkstage4
https://github.com/TheChymera/mkstage4

Both of these are based off of an older script. The first one more so than the second, but they both include most of the same files and directories. There are however a few discrepancies which I'm curious about.

1. The first script includes /dev/console and /dev/null. Why would I want these as part of my backup but not anything else under /dev?
2. The first script includes everything under /run, but I believe this is populated at boot. Why would I want this as part of my backup?
3. The first script excludes everything under /usr/local/portage except for the packages folder, and it excludes everything under /usr/src except for the /usr/src/linux-`uname -r` folder. Why would I not want the other files in those directories as part of my backup?
4. The first script includes everything under /var/lock and /var/run. Again, I believe these are populated at boot.
5. The first script includes /var/log/emerge.log but nothing else in this directory. I can see why this would be helpful, but are none of the other log files as important as this?


Last edited by Astronome on Sun Feb 14, 2016 4:49 am; edited 2 times in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sun Feb 14, 2016 1:34 am    Post subject: Re: Comparing backup scripts Reply with quote

Astronome wrote:
1. The first script includes /dev/console and /dev/null. Why would I want these as part of my backup but not anything else under /dev?

Astronome ... you'd want these as /dev/console is "the device to which system messages should be sent, and on which logins should be permitted in single-user mode", so, should something fail during early boot, you are still able to get a rescue shell. /dev/null is the standard place to redirect output that you don't want going to console/tty, and is used in early boot (by boot scripts, or what-have-you). Though having devtmpfs enabled will probably suffice, they take up no space, and won't cause any issues should they exist. I generally create /dev/tty, /dev/urandom, /dev/random, and /dev/zero also, as the very first task in init (initramfs).

Astronome wrote:
2. The first script includes everything under /run, but I believe this is populated at boot. Why would I want this as part of my backup?

I didn't look at either script but yes, they don't need to do that, /run however should exist, perhaps that was the intention.

Astronome wrote:
3. The first script excludes everything under /usr/local/portage except for the packages folder, and it excludes everything under /usr/src except for the /usr/src/linux-`uname -r` folder. Why would I not want the other files in those directories as part of my backup?

I would assume that a 'stage4' is for distribution, perhaps to more that one host, and so not exactly a 'backup'. If I were creating such a stage4 I would exclude /usr/local/portage because I don't use it for PORTDIR_OVERLAY, and other sources not matching $(name -r) could effectively be excluded as they (assuming they exist) don't match the build kernel ... that seems to me entirely the preference of the author(s), it makes the stage4 smaller, and isn't strictly needed.

Astronome wrote:
4. The first script includes everything under /var/lock and /var/run. Again, I believe these are populated at boot.

Those aren't needed, the former being a symlink to /run/lock and the latter being a symlink to /run.

Astronome wrote:
5. The first script includes /var/log/emerge.log but nothing else in this directory. I can see why this would be helpful, but are none of the other log files as important as this?

Not if the purpose of the stage4 script is to replicate an install to multiple machines, the system logger and daemons will generate these, and why copy them if the target machine is a different instance. emerge.log is different, this contains the install log of the system/stage4.

So, it depends on what purpose the script serves, a stage4 isn't strictly for "backups".

HTH & best ... khay
Back to top
View user's profile Send private message
Astronome
Tux's lil' helper
Tux's lil' helper


Joined: 02 Jan 2016
Posts: 148

PostPosted: Sun Feb 14, 2016 2:08 am    Post subject: Re: Comparing backup scripts Reply with quote

khayyam wrote:
I generally create /dev/tty, /dev/urandom, /dev/random, and /dev/zero also, as the very first task in init (initramfs).


Are you saying it would be a good idea to include these in a backup as well? (obviously that's what I'm using it for)

Quote:
If I were creating such a stage4 I would exclude /usr/local/portage because I don't use it for PORTDIR_OVERLAY


I just realized this directory doesn't even exist on my system. What would it be used for, exactly? A local package repository?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sun Feb 14, 2016 3:05 am    Post subject: Re: Comparing backup scripts Reply with quote

Astronome wrote:
khayyam wrote:
I generally create /dev/tty, /dev/urandom, /dev/random, and /dev/zero also, as the very first task in init (initramfs).

Are you saying it would be a good idea to include these in a backup as well? (obviously that's what I'm using it for)

Astronome ... in my case they are created at the initramfs stage, then before I switch_root I 'mount --move /dev /newroot/dev', so it wouldn't matter. I was simply explaining the reasoning behind creating them, or including them in the stage4, but as I said if you have CONFIG_DEVTMPFS you can probably depend on them being there (I don't because the initramfs isn't tied to any particular kernel, and so it will work if that is enabled or not).

Astronome wrote:
khayyam wrote:
If I were creating such a stage4 I would exclude /usr/local/portage because I don't use it for PORTDIR_OVERLAY

I just realized this directory doesn't even exist on my system. What would it be used for, exactly? A local package repository?

Yes ... and though I have a local overlay, and other repo's, I keep them all (including the 'gentoo' repo ... confusingly called 'portage') in the same location

Code:
# for i in PORTDIR PORTDIR_OVERLAY ; do eix --print $i ; done
/var/pkg/gentoo/
/var/pkg/foo-overlay
/var/pkg/local
/var/pkg/mv

best ... khay
Back to top
View user's profile Send private message
Astronome
Tux's lil' helper
Tux's lil' helper


Joined: 02 Jan 2016
Posts: 148

PostPosted: Sun Feb 14, 2016 4:56 am    Post subject: Reply with quote

I tried, but I can't get used to using tarballs as backups. I decided to roll my own backup script using rsync, which you can find here.

There's a patch for Arch and one for Gentoo:

Code:

git apply backup-gentoo.diff


Here's how it compares to the other backup scripts regarding default included/excluded files:

Code:

f = include (non-recursive), * = include (recursive)

                            gsra99  TheChymera  mine
/bin                        *       *           *
/boot                       *       *           *
/dev                        f       f           f
    /console                f                   f
    /null                   f                   f
/etc                        *       *           *
/home                       *       *           *
/lib                        *       *           *
/lib64                      *       *           *
/lost+found                 f       f           f
/media                      f       f           f
/mnt                        f       f           f
    /*                              f           f
        /.keep              f
    /ICYBOX                 f       f           f
/opt                        *       *           *
/proc                       f       f           f
/root                       *       *           *
/run                        *       f           f
/sbin                       *       *           *
/srv                        *       *           *
/sys                        f       f           f
/tmp                        f       f           f
/usr                        *       *           *
    /local                  *       *           *
        /portage            f       *           *
            /packages       *       *           *
    /portage                f       f           f
    /src                    f       *           *
        /linux-`uname -r`   *       *           *
/var                        *       *           *
    /lock                   *       f           *
    /log                    f       f           f
        /emerge.log         f                   f
    /run                    *       f           *


As you can see, mine includes everything under /usr/local/portage (if I had this directory I would probably exclude it) and /usr/src (I keep other stuff in there besides kernel sources). I also include /var/lock and /var/run, but since they both symlink to /run and /run is excluded it doesn't matter.

The only reason /mnt/ICYBOX is specifically mentioned is because the gsra99 script includes it by default but requires .keep files for any other directories under /mnt. My script (as well as the one from TheChymera) will include directories under /mnt but exclude any files therein.


Last edited by Astronome on Thu Mar 03, 2016 4:51 am; edited 1 time in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sun Feb 14, 2016 11:29 am    Post subject: Reply with quote

Astronome wrote:
I decided to roll my own backup script using rsync, which you can find here.

Astronome ... the only comment I might make is that excluding .git will lead to your having repos (ie, from layman, or other 'git clone'd repositories) copied but no longer under git version control (and so pullable). You may want to rethink that exclusion.

best ... khay
Back to top
View user's profile Send private message
Astronome
Tux's lil' helper
Tux's lil' helper


Joined: 02 Jan 2016
Posts: 148

PostPosted: Mon Feb 15, 2016 3:17 am    Post subject: Reply with quote

khayyam wrote:
Astronome wrote:
I decided to roll my own backup script using rsync, which you can find here.

Astronome ... the only comment I might make is that excluding .git will lead to your having repos (ie, from layman, or other 'git clone'd repositories) copied but no longer under git version control (and so pullable). You may want to rethink that exclusion.

best ... khay


Ah, good point. I will change that. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum