• att BitTwister

    From faeychild@2:250/1 to All on Wed Nov 13 02:53:38 2019


    Hi Bits

    the time is coming to backup "/"

    I know for sure that typing the command into the sysrescue terminal is
    going to cause fat finger and blind eye syndrome

    A script is a better way to go.

    So I thought I'd ask your approach.

    How do you access the script.

    Did you install in the sysrescue ISO?
    Did you install on the "src" filesystem
    Or a method I haven't thought off?

    ******************
    ************ Trial script
    *********** backup only
    #! /bin/bash
    #
    #
    #

    _mga_7=/dev/nvme0n1p2/
    _mga_bu=/dev/nvme0n1p5/

    mkdir /src
    mkdir /dest

    mount -t auto $_mga_7 /src
    mount -t auto $_mga_bu /dest

    rsync -aAHSXxv /src/ --exclude={"/dev/*,"/proc/*","/sys/*","tmp/*","/run/*","/mnt/*","/video/*","/me dia/*","/lost+found"}
    /dest

    ## end******************************




    NAME SIZE FSTYPE LABEL MOUNTPOINT PARTLABEL
    sda 5.5T
    └─sda1 5.5T ext4 video /video video
    sdb 29.7G
    └─sdb1 29.7G vfat /run/media/nykysle/6436-3731
    sr0 1024M
    nvme0n1 119.2G
    ├─nvme0n1p1 299M vfat /boot/EFI efi ├─nvme0n1p2 22.3G ext4 mageia / mageia ├─nvme0n1p3 10.6G swap swap [SWAP] swap ├─nvme0n1p4 12.2G ext4 tmp /tmp tmp ├─nvme0n1p5 20.4G ext4 mageia_bu mageia_bu ├─nvme0n1p6 2G ext4 boot_iso boot_iso └─nvme0n1p7 24.9G ext4 mageia_6 mageia_6



    regards
    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.7-desktop-4.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Wed Nov 13 05:12:08 2019
    On Wed, 13 Nov 2019 13:53:38 +1100, faeychild wrote:

    Subject: att BitTwister

    I thought I mentioned you did not need att BitTwister in subject line.
    I can suggest you always use a subject line to get subject matter
    experts attention.

    Some people my take your current subject as wanting a personal thread
    without anyone else partition.

    I took the liberty of changing it to a more appropriate which will
    make it easier for anyone looking to do the same thing to find the
    thread in the future.

    Hi Bits
    Evening faeychild

    the time is coming to backup "/"

    I should hope so. :)


    I know for sure that typing the command into the sysrescue terminal is
    going to cause fat finger and blind eye syndrome

    A script is a better way to go.

    I would agree/suggest so. With a little effort, it can be made to
    also keep you out of trouble.

    So I thought I'd ask your approach.

    How do you access the script.

    Boot other install run level 3
    login as root
    bkup_mga7
    or
    restore_mga7
    for whichever way wanting to do what to mga7

    If booted runlevel 5 (gui)
    click up a terminal
    su - root
    bkup_mga7



    Did you install in the sysrescue ISO?

    No. I always install on my system using Mageia iso.

    Did you install on the "src" filesystem
    Or a method I haven't thought off?

    Or I have no good idea what "install" means.

    Starting to guess, you are asking about the script install and how to
    launch it.

    Placing script on a rescue cd, means you have to repeat the script install anytime you modify the script or a new release of the rescue media is installed.
    That is way too much maintenance for me.

    Having said that, method/launch depends on system setup.
    I have a separate partition for my system wide stuff,
    $ ls /local
    bin cron icons log opt ppp tmp
    config doc lock lost+found phone sounds

    /local/bin has my system wide scripts, icons for desktop icons to keep
    the same look regardless of install/desktop, sounds for playing wav files
    for error, success, mail,.....

    What that allows me to do when required to use a rescue media is
    mkdir /local
    mount -t auto LABEL=local /local
    /local/bin/restore_mga7 or
    /local/bin/bkup_mga7

    ******************
    ************ Trial script
    *********** backup only
    #! /bin/bash
    #
    #
    #

    _mga_7=/dev/nvme0n1p2/
    _mga_bu=/dev/nvme0n1p5/

    Hard coding device partition id is not my preferred method, can be error
    prone, devastating if you add/delete/re-partition/move install, ......

    Seems like I spent a week or more trying to get you to use label/name
    for your partitions. Tell me if the following is less error prone or not.

    _src=mageia
    _dest=mageia_bu

    That makes it bit more obvious as to which is what. As coded, indicates
    you will need another script to do a restore. You may be surprised to
    find out how easy it will be to use command line arguments to pick doing
    a backup or restore, or different partitions with the same script.

    Come Mageia release 8, may cause more problems.

    Yes, I know it is just a beginning point, I just want you keep it in mind.


    mkdir /src
    mkdir /dest

    Using the above label names in the variables, the mount command becomes

    mount -t auto LABEL=$_src /src
    mount -t auto LABEL=$_dest /dest

    rsync -aAHSXxv /src/

    --exclude={"/dev/*,"/proc/*","/sys/*","tmp/*","/run/*","/mnt/*","/video/*","/me dia/*","/lost+found"}
    /dest

    ## end******************************

    I can recommend just
    rsync -aAHSXxv /src/ /dest
    at this point, when not attempting to back up an unmounted / partition.

    All those /whatever excludes are needed if attempting to backup
    a running / and if you were to check each argument as to what it does,
    you might find one or more which tells rsync to not go outside of the
    partition for files.

    In other words you did not have to exclude /video and none of the other partitions are not actually there unless you are actually running in /.

    lost+found is the exception. Normally all partitions get
    a lost+found. I do not bother excluding it, because there is nothing
    in it unless something clobbered inode chain. which cause best guess
    of the file to be placed in lost+found.

    If doing a restore, I suggest you would want it to be restored. :)

    I have a cron job always checking lost+fouund partitions on my system
    to warn be about the problem.

    As coded to date, it is doing the desired commands put without any
    checking of return status. You can test for successful operation by
    checking $? for non-zero value. That applies to the great majority of
    apps. However I have see one or two, which do not. Always best to check
    man page of app to see if exceptions exists.

    Quick down and dirty example:
    rsync -aAHSXxv /src/ /dest
    if [ $? -ne 0 ] ; then
    echo " Fatal error 1 running rsync -aAHSXxv /src/ /dest"
    exit 1
    fi

    Homework, man test


    For anyone coding, You might think about the 6 P's
    Prior Planning Prevents Piss Poor Performance.

    When starting out to code a script, I can recommend writing down all the requirements required of the script. That way you can use the majority
    of those as comments to make it easy to find the operation, and to know
    you have completed coding all of the requirements.

    Yes, I know this is just a beginning script, but you will get a better
    product quicker in the long run. If you are not going to document
    all the requirements and just start hacking out code, you need to stop
    at each line of code and think about Murphy helping you into the ditch.

    I suggest idiot proofing the code and lots to tests to help you to locate problems much faster than having to research code operation to find out
    about a problem during real world operation.

    Some examples:
    Can only run as root
    can not run if running / is to be restore/backed up.
    src/dest do not exists
    src/dest can not be the same

    By the way, I find that when I have to duplicate something it is better
    to have it in one place to keep maintenance down if requiring change.

    Take your rsync arguments as example in this code snippet. That way
    rsync_args can be in one place for change, and have the additional
    benefit of the code being able to change them without having to
    dink around with duplicate rsync lines to do different type of backup.

    script -c "rsync $_rsync_args /src/ /dest" $_rsync_log_fn
    _rtn_status=$?
    if [ $_rtn_status -ne 0 ] ; then
    echo "Fatal $_exe error 15 running
    rsync $_rsync_args /src/ /dest
    return status: $_rtn_status
    log: $_rsync_log_fn
    "
    exit $_rtn_status
    fi

    Homework man script

    Another tip, I like using _app and _exe in my code. That allow me much
    more flexibility than hard coding the names and improves
    maintenance/coding time. Example:

    _app=${0##*/}
    _exe=$0
    _temp_dir=/somewhere


    _report_fn"$_temp_dir/$_app.rpt"
    _rsync_log_fn="$_temp_dir/${_app}_rsync.log"
    _temp_fn="$_temp_dir/$_app.tmp"


    Take my backup/restore script (bkup_restore) for example.
    One script, but executed using different names.

    Maintenance wise, I just create another link for new releases, and delete
    links of old releases. At the moment a ls -al /local/bin snippet
    bkup_restore
    bkup_mga4 -> bkup_restore
    bkup_mga5 -> bkup_restore
    bkup_mga6 -> bkup_restore
    bkup_mga61 -> bkup_restore
    bkup_mga7 -> bkup_restore
    bkup_mga71 -> bkup_restore
    restore_mga4 -> bkup_restore
    restore_mga5 -> bkup_restore
    restore_mga6 -> bkup_restore
    restore_mga61 -> bkup_restore
    restore_mga7 -> bkup_restore
    restore_mga71 -> bkup_restore
    restore_net_ins -> bkup_restore

    bkup_restore parses $_app to get what to do bkup/restore
    and source directory name.
    Saves me having to call script with what to do with whom arguments.

    set -- $(IFS='_' ; echo $_app)
    $1 will have bkup or restore
    $2 will have source partition label.

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Daniel60@2:250/1 to All on Wed Nov 13 13:42:46 2019
    Bit Twister wrote on 13/11/2019 4:12 PM:
    On Wed, 13 Nov 2019 13:53:38 +1100, faeychild wrote:

    <Snip a lot of stuff that I'll have to re-read to make sure I even get
    close to understanding>

    Thank you, Bit Twister, for this detailed response to faeychild's
    original post, and thank you, faeychild for that post. I've been meaning
    to post a question here on doing back-ups for a while .... so here goes ...

    I dual/multi boot Win7 with several installs of Mageia Linux and, as I
    use SeaMonkey Internet Suite under both Linux and Win7, I have the Linux SeaMonkeys using the Profile on one of my Win7 partitions, e.g. my
    Windows E:\ partition.

    So, when I use Konqueror/Dolphin to look at my partitions, I can 'see'
    my Win disks (under /media/Win, /media/Executables and /media/Games, I
    think).

    When I do a back up, I back up the Win7 partitions (sda1, sda2 and sda3)
    as separate items ...... but does the above mean that when I then back
    up my MageiaLinux partitions (sda6, sda7, sda8 (/Home), etc), will I be re-backing up my Win7 directories as part of the /sda6 and /sda7 back ups??

    Or can I exclude the Win7 partitions when I back up the Linux /sda6 or
    /sda7 partitions, maybe by excluding the /media mount point from the
    back up process??

    (I hope this makes sense to you .... I'm not sure it does to me, but I
    tried!)

    TIA, anyway.

    --
    Daniel

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Wed Nov 13 14:25:46 2019
    On Wed, 13 Nov 2019 13:53:38 +1100, faeychild wrote:

    ******************
    ************ Trial script
    *********** backup only
    #! /bin/bash

    Personally I prefer
    #!/bin/bash

    Usual first line of code in my scripts is to set the PATH variable.
    I source a file which gives me one place to modify PATH for all my scripts.

    After that is something like set -u.
    I have found it handy to have a boilerplate/skeleton script for different activities.
    $ ls *skel*
    bash_skeleton skeleton_service_changes install_skeleton skeleton_changes

    That way I can "cp bash_skeleton bkup" and start remove/adding code in
    bkup script. A quick global substitution of bash_skeleton and skeleton
    to bkup makes default text match script name.

    It has code for help/usage, parsing command line arguments,
    different code snippets common to different activities and whatnot.
    Take the first 12 lines of bash_skeleton for example:

    $ head -12 bash_skeleton
    #!/bin/bash
    #************** Start bash_skeleton ********************************
    #*
    #* bash_skeleton - skeleton installer
    #*
    #********************************************************************

    . /local/bin/functions_path_app
    . /local/bin/functions_xmsg

    set -u # Show usage of unset variables as an error to help catch typos.

    functions_path_app sets PATH, and numerous variables to allow me to code faster.

    functions_xmsg has several functions to allow me to pop up messages in different colors, and get selection answers and whatnot using xmessage.

    I found https://www.tldp.org/LDP/abs/html/index.html as a handy reference.

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Wed Nov 13 14:55:19 2019
    On Thu, 14 Nov 2019 00:42:46 +1100, Daniel60 wrote:
    ink).

    When I do a back up, I back up the Win7 partitions (sda1, sda2 and sda3)
    as separate items ...... but does the above mean that when I then back
    up my MageiaLinux partitions (sda6, sda7, sda8 (/Home), etc), will I be re-backing up my Win7 directories as part of the /sda6 and /sda7 back ups??

    All depends on tool/app being used and arguments given.

    Or can I exclude the Win7 partitions when I back up the Linux /sda6 or
    /sda7 partitions, maybe by excluding the /media mount point from the
    back up process??

    Heheh, yes.

    (I hope this makes sense to you .... I'm not sure it does to me, but I tried!)

    Ok, in a nutshell, you can use rsync to only copy one partition at a time
    and only the contents of the partition. If you were to do a "man rsync"
    you might notice there are all sorts controls/options,....

    How you go about doing the rsync and your requirements defines if you
    want to use exclude or not.

    I want the cleanest most correct backup possible. Backing up / while it
    is in use, is not getting what I want.

    It is dead simple to get a complete clean backup of a / partition if you
    boot some other install and run the backup.

    I have a rsync_b script which reads my external backup drive via the usb
    port. The script gets a list of partitions on the backup drive,
    and rsyncs those partitions if the partition is not the current partition.
    If so it skips it. I then boot some other install, run it again,
    and rsync has noting new to add to previous syncs, but does update the
    previous partition what was skipped.

    If not using media label or partition name, it becomes a maintenance
    headache to have the script use device names (sda6, sda7, sda8...)

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From faeychild@2:250/1 to All on Thu Nov 14 02:53:59 2019
    On 14/11/19 1:25 am, Bit Twister wrote:
    On Wed, 13 Nov 2019 13:53:38 +1100, faeychild wrote:

    ******************
    ************ Trial script
    *********** backup only
    #! /bin/bash


    There you go!!!
    You mentioned Murphy and ditches
    I don't need that much assistance to stuff up

    That line "#! /bin/bash", with the space, was cut and pasted and I still didn't spot it. :-(

    And you did also create a much better approach that I never thought off.

    I was blinkered into seeing systemrescue - totally unnecessarily .

    So now I have some script analysis to do

    Regards
    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.7-desktop-4.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From faeychild@2:250/1 to All on Thu Nov 14 03:19:47 2019
    On 13/11/19 4:12 pm, Bit Twister wrote:

    also keep you out of trouble.

    So I thought I'd ask your approach.

    How do you access the script.

    Boot other install run level 3
    login as root
    bkup_mga7
    or
    restore_mga7
    for whichever way wanting to do what to mga7

    If booted runlevel 5 (gui)
    click up a terminal
    su - root
    bkup_mga7

    Excellent!! And obviously better

    Did you install in the sysrescue ISO?

    No. I always install on my system using Mageia iso.

    Did you install on the "src" filesystem
    Or a method I haven't thought off?


    Starting to guess, you are asking about the script install and how to
    launch it.

    well deduced.. I must try to be less cryptic



    Placing script on a rescue cd, means you have to repeat the script install anytime you modify the script or a new release of the rescue media is
    installed.
    That is way too much maintenance for me.

    Obvious- now


    Having said that, method/launch depends on system setup.
    I have a separate partition for my system wide stuff,
    $ ls /local
    bin cron icons log opt ppp tmp
    config doc lock lost+found phone sounds


    I'll see how far I get understanding your script



    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.7-desktop-4.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Thu Nov 14 06:14:33 2019
    On Thu, 14 Nov 2019 14:19:47 +1100, faeychild wrote:


    I'll see how far I get understanding your script

    Speaking of which, I highly recommend using long argument name instead
    of short form. Makes it much easier to see what is going on month/years
    later. Examples:
    rm -fr ..... :(
    rm --force --recursive :)
    _rsync_args="--archive --acls --hard-links --sparse --xattrs --one-file-system --quiet"

    I'll usually run some_cmd --help to get long switch/argument name.


    With a little thought you can make your backup script ambidextrous.

    To do a restore, you would just reverse the $_src and $_dest contents.

    If you chose to not use $_app name to decide what to do, it is easy
    enough to get command line arguments as what to do to whom.
    Google can be your friend.
    About 16,900,000 results (0.61 seconds)
    with
    parse bash command line arguments
    in the first box at
    https://encrypted.google.com/advanced_search


    Coding/running as root is a bit dangerous.
    You can do a very large amount of work in your user account.

    For instance you can put an echo in front of the rsync command
    just to see how bash would execute it. Example:

    echo rsync $_rsync_args $_src/ $_dest
    if [ $? -ne 0 ] ; then
    _rtn_status=$?
    whatever


    If you want to check the status/error code,
    echo rsync $_rsync_args $_src/ $_dest
    false; if [ $? -ne 0 ] ; then
    _rtn_status=$?
    whatever

    Note that I am always indenting the code about two spaces.
    Makes it easier to see the scope of the statement.

    Warning, use of tabs for indention will prevent you from cut/pasting
    code in a terminal.

    Speaking of which, I always have a terminal or two open when coding.
    When in doubt, I'll paste commands/code from script in a terminal
    to see what shows up.

    With the above examples, you might notice I put the echo, false; to the
    far left. That allows me to find the debugging code and remove it when
    ready for a real world test. Another tip for blocking out code is an
    if statement around code. For example, you put a test in which checks
    if you are root and if not exit. That code would make it hard to continue verifying that the rest of the code works if running as a user. Solution:

    if [ 0 -eq 1 ] ; then
    if [ ....
    echo ...
    ...
    exit 1
    fi
    fi # end if [ 0 -eq 1 ]


    When done testing you remove the if [ 0 and its fi line prior to running
    it for real.

    If you were to put return status check after each command, you might
    notice there is more checking code than running code and not as easy
    to follow as having no checks. You can use a function to reduce clutter.
    https://www.tldp.org/LDP/abs/html/functions.html

    When in long lines of code that might span a page if printed, I will
    break out code into functions to make it easier to create code that is
    easier to follow. Look how much easier it is to see what is going on here

    mkdir /src
    ck_status "mkdir /src"

    mount -t auto LABEL=$_src /src
    ck_status "mount -t auto LABEL=$_src /src"

    mkdir /dest
    ck_status "mkdir /dest"

    mount -t auto LABEL=$_src /dest
    ck_status "mount -t auto LABEL=$_src /dest"

    This way your ck_status function, checks $? and if fails, still issue
    what command failed and exit. Example:
    function ck_status ()
    {
    if [ $? -ne 0 ] ; then
    _rtn_status=$?
    _arg_1="$@"
    echo " $_exe error running
    $_arg_1
    returned $_rtn_status
    "
    exit $_rtn_status
    fi
    } # end function ck_status

    While here I would mention you might consider an error clean up function.
    In this app, it would silently umount possible mounts. Example
    function cleanup ()
    {
    umount $_src > /dev/null 2>&1
    umount $_src > /dev/null 2>&1
    exit $_rtn_status
    } # end function cleanup

    and your ck_status function would have
    returned $_rtn_status
    "
    cleanup
    fi

    Any other clean up activities would also be in cleanup like deleting
    any temp files or whatever.

    I can agree that in this app, you could just put the two umount commands
    before the ck_status exit and not bother with a cleanup function.

    I was just trying to give the reader things to consider when coding.

    By the way, what code I post in these kinds of discussions may not be the
    best method or most efficient. They are to help/show how to do something
    or a suggestion/hint to get a desired result.

    Oh, yeah, you might take time to think how all this backup going to work.

    In my setup, I run my new_boot_logs script which deletes/wipes numerous
    log files, and reboot.

    I pick another install in grub menu, run backup/restore as desired, upon completion, script either reboots back into "Production" or just power down
    the system when done.

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Daniel60@2:250/1 to All on Thu Nov 14 09:58:28 2019
    Bit Twister wrote on 14/11/2019 1:55 AM:
    On Thu, 14 Nov 2019 00:42:46 +1100, Daniel60 wrote:
    ink).

    When I do a back up, I back up the Win7 partitions (sda1, sda2 and sda3)
    as separate items ...... but does the above mean that when I then back
    up my MageiaLinux partitions (sda6, sda7, sda8 (/Home), etc), will I be
    re-backing up my Win7 directories as part of the /sda6 and /sda7 back ups??

    All depends on tool/app being used and arguments given.

    Or can I exclude the Win7 partitions when I back up the Linux /sda6 or
    /sda7 partitions, maybe by excluding the /media mount point from the
    back up process??

    Heheh, yes.

    (I hope this makes sense to you .... I'm not sure it does to me, but I
    tried!)

    Ok, in a nutshell, you can use rsync to only copy one partition at a time
    and only the contents of the partition. If you were to do a "man rsync"
    you might notice there are all sorts controls/options,....

    How you go about doing the rsync and your requirements defines if you
    want to use exclude or not.

    I want the cleanest most correct backup possible. Backing up / while it
    is in use, is not getting what I want.

    It is dead simple to get a complete clean backup of a / partition if you
    boot some other install and run the backup.

    I have a rsync_b script which reads my external backup drive via the usb port. The script gets a list of partitions on the backup drive,
    and rsyncs those partitions if the partition is not the current partition.
    If so it skips it. I then boot some other install, run it again,
    and rsync has noting new to add to previous syncs, but does update the previous partition what was skipped.

    If not using media label or partition name, it becomes a maintenance
    headache to have the script use device names (sda6, sda7, sda8...)

    O.K.!! You Live ... You Learn (I think!!)

    Bit Twister, if I'm reading what you typed above correctly, are you
    suggesting that rsync, effectively, creates one back up of the internal
    Hard Drive on the external Hard Drive ... and then updates that back up
    each time rsync is run?? (Is the clue in the word "rsync"?? *sync* )

    I had been thinking of having multiply redundancies of my internal HD
    (500GB) by, each three moths or so, maybe, creating a new, complete,
    back up of my internal HD (500GB) partitions on the Ext HD (2TB).

    Additional Question, if I may .... This Laptop is becoming a bit 'iffy'
    being twelve years or so old. Currently to get it to boot, I have a MGA6
    DVD in the drive and, when its menu comes up, I select to boot from the
    HD ... and away I go. Not having completely checked out the DVD menu,
    should I be able to get to the system level (Run Level Three (or
    whatever)) at a suitable location to Rsync *all* partitions in one go,
    or would I still have to boot into another system (MGA5 maybe) to Rsync
    my main system (MGA6) to the Ext HD??

    Additional Additional Question if I may ... or tell me to bugger off if
    you like ;-) .. If I Rsync my Int HD to Ext HD, including the four Linux
    OS's and then I blow away, say, my MD2009.1 (sda6) from the Int HD and
    install MGA7 in that partition, when next I Rsync my Int HD to the Ext
    HD, will it also blow away the MD2009.1 or will I just be using up some
    of the otherwise unused space on the Ext HD??

    --
    Daniel

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Thu Nov 14 12:29:07 2019
    On Thu, 14 Nov 2019 20:58:28 +1100, Daniel60 wrote:
    Bit Twister wrote on 14/11/2019 1:55 AM:

    If not using media label or partition name, it becomes a maintenance
    headache to have the script use device names (sda6, sda7, sda8...)

    O.K.!! You Live ... You Learn (I think!!)

    If you were to hunt around for Usenet Etiquette, One of the rules/suggestion
    is to trim your reply down to just enough of original post to give
    context to what you are replying to.


    Bit Twister, if I'm reading what you typed above correctly, are you suggesting that rsync, effectively, creates one back up of the internal
    Hard Drive on the external Hard Drive ... and then updates that back up
    each time rsync is run??

    A bit more precisely, the script backs up a partition from the internal
    drive (source) to the external drive (destination).
    Not all partitions on the internal drive are on the external drive in my setup.

    (Is the clue in the word "rsync"?? *sync* )

    rsync is the application being used to do the backup.
    When you want to look into something of interest you might want to try
    using "man app_name_here" to see if you can get more information.

    The problem there could be if the app is not installed, or you are not
    running Linux at the time. In that case you should try a search engine
    like Google or duckduckgo. Example search string
    linux rsync man or linux man rsync where you might click a selection
    which sends you to https://linux.die.net/man/1/rsync

    I had been thinking of having multiply redundancies of my internal HD
    (500GB) by, each three moths or so, maybe, creating a new, complete,
    back up of my internal HD (500GB) partitions on the Ext HD (2TB).

    In a nutshell, rsync starts out by making a complete copy, and thereafter
    will update any changes to the copy to make it match.

    Additional Question, if I may .... This Laptop is becoming a bit 'iffy'
    being twelve years or so old. Currently to get it to boot, I have a MGA6
    DVD in the drive and, when its menu comes up, I select to boot from the
    HD ... and away I go. Not having completely checked out the DVD menu,
    should I be able to get to the system level (Run Level Three (or
    whatever)) at a suitable location to Rsync *all* partitions in one go,

    That tells me you will not be able boot to a specific runlevel unless
    you are extremely competent. I.E. Way over my level of experience.

    or would I still have to boot into another system (MGA5 maybe) to Rsync
    my main system (MGA6) to the Ext HD??

    And right there is the exact methodology that I am pushing in this thread.

    Additional Additional Question if I may ...

    No need to keep asking permission.

    or tell me to bugger off if you like ;-) ..

    I just would not bother to respond and someone else might ask your question.

    If I Rsync my Int HD to Ext HD, including the four Linux
    OS's and then I blow away, say, my MD2009.1 (sda6) from the Int HD and install MGA7 in that partition, when next I Rsync my Int HD to the Ext
    HD, will it also blow away the MD2009.1 or will I just be using up some
    of the otherwise unused space on the Ext HD??

    Depending on rsync arguments, for example ones you find in the thread,
    if the destination file/content is not the same as on the source, the destination file is deleted and replaced by the source copy.
    If a file on the destination is not on the source media, it is deleted
    on the destination media.

    How/what rsync does will depend on the arguments/switchs used in the
    operation.


    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From faeychild@2:250/1 to All on Sun Nov 17 20:29:35 2019
    On 14/11/19 1:25 am, Bit Twister wrote:

    Hi Bits

    An early start here to avoid interruptions.

    I ran "rsync" with the usual rookie error

    YOU NEED TO BE ROOT!!!!

    AHHHGG ! damn damn

    It took a little over four minutes to run and verbose outputs are
    instructive to watch

    I didn't know I had ".local/share/Trash/*"

    hidden away!! :-)

    The backup partition seems nicely populated. We obviously succeeded.

    regards


    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.7-desktop-4.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Sun Nov 17 21:30:03 2019
    On Mon, 18 Nov 2019 07:29:35 +1100, faeychild wrote:
    On 14/11/19 1:25 am, Bit Twister wrote:

    Hi Bits

    An early start here to avoid interruptions.

    I ran "rsync" with the usual rookie error

    YOU NEED TO BE ROOT!!!!

    Yep, that is why I suggested you need to have defined your requirements
    like test for root user, verify not trying to backup/restore if source
    or destination is mounted,...

    --- MBSE BBS v1.0.7.12A (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From faeychild@2:250/1 to All on Mon Nov 25 02:44:12 2019
    On 18/11/19 8:30 am, Bit Twister wrote:


    Yep, that is why I suggested you need to have defined your requirements
    like test for root user, verify not trying to backup/restore if source
    or destination is mounted,...

    That is a good point.
    Even though it's unlikely when running through a "junk" account, it
    could happen.
    I ran rsync for the second time - pre update, and it was quicker.

    Script so far
    *************
    #!/bin/bash
    #
    #
    # Program to backup current installation
    # Mageia_7 to a backup partition mageia_bu


    # Check if user has root permissions
    if ! [ $(id -u) = 0 ]; then
    echo "Script must run as Root!"
    exit 1
    fi


    # define partitions using partition labels
    _src=mageia
    _dest=mageia_bu


    # create partition mount points
    mkdir /src
    mkdir /dest


    # mount source and destination partitions on mount points
    mount -t auto LABEL=$_src /src
    mount -t auto LABEL=$_dest /dest


    # run backup script
    rsync --archive --acls --hard-links --sparse --xattrs
    --one-file-system --verbose /src/ /dest


    ## end


    Not at all elaborate. Bits, but it ran

    regards


    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.7-desktop-4.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Mon Nov 25 05:37:59 2019
    On Mon, 25 Nov 2019 13:44:12 +1100, faeychild wrote:
    On 18/11/19 8:30 am, Bit Twister wrote:


    Yep, that is why I suggested you need to have defined your requirements
    like test for root user, verify not trying to backup/restore if source
    or destination is mounted,...

    That is a good point.
    Even though it's unlikely when running through a "junk" account, it
    could happen.
    I ran rsync for the second time - pre update, and it was quicker.

    Script so far
    *************
    #!/bin/bash
    #

    Would not hurt to put script name here


    # Check if user has root permissions
    if ! [ $(id -u) = 0 ]; then

    Inefficient coding. You are converting integer to string for testing.
    The ! could be placed in front of = to do not equal string test.

    Please run "man test"

    # create partition mount points
    mkdir /src
    mkdir /dest

    If directory already exist, mkdir will throw an error.

    # mount source and destination partitions on mount points
    mount -t auto LABEL=$_src /src
    mount -t auto LABEL=$_dest /dest

    # run backup script
    rsync --archive --acls --hard-links --sparse --xattrs
    --one-file-system --verbose /src/ /dest


    ## end

    Noticed you are not testing status/return code from commands.

    Also, you did not dismount mounted /src and /dest


    Not at all elaborate. Bits, but it ran

    Yup, now you can consider how you want it to work for a restore.

    Here is just some suggested changes.
    - ---8<---8<---8<---8<---8<--cut below this line -8<---8<---8<---8<---8< #!/bin/bash
    #
    #
    # Program to backup current installation
    # Mageia_7 to a backup partition mageia_bu

    set -u # Show usage of unset variables as an error to help catch typos.

    _app=${0##*/} # script name
    _dev_label="" # / device label
    _exe=$0 # /wherever/script_name

    # Check if user has root permissions
    if [ $(id -u) -ne 0 ]; then
    echo "$_exe Fatal error 1: $_app must run as Root!"
    exit 1
    fi

    # define partitions using partition labels
    _src=mageia
    _dest=mageia_bu

    # get /'s media label
    set -- $(mount --show-labels | grep ' / ' | tr '[]' ' ')
    shift $(($#-1))
    _dev_label=$1

    # verify source is not mounted as /
    if [ "$_dev_label" = "$_src ] ; then
    echo "$_exe Fatal error 2: $_src already mounted as /
    $_app will not backup $_src when $_src mounted as /"
    exit 1
    fi

    # create partition mount points, suppress error if already exists
    mkdir --parents /src
    mkdir --parents /dest


    # mount source and destination partitions on mount points
    mount -t auto LABEL=$_src /src
    mount -t auto LABEL=$_dest /dest


    # run backup script
    rsync --archive --acls --hard-links --sparse --xattrs \
    --one-file-system --verbose /src/ /dest

    umount /src
    umount /dest

    ## end

    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From faeychild@2:250/1 to All on Tue Nov 26 06:10:54 2019
    On 25/11/19 4:37 pm, Bit Twister wrote:

    ---8<---8<---8<---8<---8<--cut below this line -8<---8<---8<---8<---8< #!/bin/bash
    #
    #
    # Program to backup current installation
    # Mageia_7 to a backup partition mageia_bu

    set -u # Show usage of unset variables as an error to help catch
    typos.

    _app=${0##*/} # script name
    _dev_label="" # / device label
    _exe=$0 # /wherever/script_name


    # print variables to see what is going on
    echo "_app="$_app, "_exe="$_exe, "_dev_label="$_dev_label



    # Check if user has root permissions
    if [ $(id -u) -ne 0 ]; then
    echo "$_exe Fatal error 1: $_app must run as Root!"
    exit 1
    fi

    # define partitions using partition labels
    _src=mageia
    _dest=mageia_bu

    # get /'s media label
    set -- $(mount --show-labels | grep ' / ' | tr '[]' ' ')
    OK! The mount instruction pulls up the data string of the partition
    mounted on root
    The translate command removes the square brackets around the label name leaving you with "mageia" or is that $(mageia)
    I don't understand the association with "set" or set itself






    # verify source is not mounted as /
    if [ "$_dev_label" = "$_src" ] ; then
    echo "$_exe Fatal error 2: $_src already mounted as /
    $_app will not backup $_src when $_src mounted as /"
    exit 1
    fi

    Very nice. The script fails if run on the system to be backed up



    # create partition mount points, suppress error if already exists
    mkdir --parents /src
    mkdir --parents /dest

    I looked up "parents" that's a nice feature to



    Still dinking around with the script

    regards


    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.7-desktop-4.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Tue Nov 26 07:26:23 2019
    On Tue, 26 Nov 2019 17:10:54 +1100, faeychild wrote:


    # get /'s media label
    set -- $(mount --show-labels | grep ' / ' | tr '[]' ' ')
    OK! The mount instruction pulls up the data string of the partition
    mounted on root
    The translate command removes the square brackets around the label name leaving you with "mageia" or is that $(mageia)

    Not quite sure what you mean. On something like that you can just paste
    the command in a terminal and see what is what. Example:
    mount --show-labels | grep ' / ' | tr '[]' ' '

    I don't understand the association with "set" or set itself

    set is a builtin command. It will break the provided line into arguments
    which you can use to store into variables. paste the following in a terminal.

    mount --show-labels | grep ' / ' | tr '[]' ' '

    set -- $(mount --show-labels | grep ' / ' | tr '[]' ' ')
    echo "arg 1 is $1"
    echo "arg 2 is $2"
    echo "arg 3 is $3"
    echo "arg 4 is $4"
    echo "arg 5 is $5"

    You might consider going to
    https://www.tldp.org/LDP/abs/html/index.html
    Hit Ctrl+f and enter a space set space in the search/find box.





    # verify source is not mounted as /
    if [ "$_dev_label" = "$_src" ] ; then
    echo "$_exe Fatal error 2: $_src already mounted as /
    $_app will not backup $_src when $_src mounted as /"
    exit 1
    fi

    Very nice. The script fails if run on the system to be backed up

    You also need to test that $_dest is not mounted at /
    if you are doing a "restore"



    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From faeychild@2:250/1 to All on Thu Nov 28 03:17:23 2019



    You might consider going to
    https://www.tldp.org/LDP/abs/html/index.html
    Hit Ctrl+f and enter a space set space in the search/find box.

    I will remember "space" keyword "space" , Bits

    Thanks


    --
    faeychild
    Running plasmashell 5.15.4 on 5.3.11-desktop-1.mga7 kernel.
    Mageia release 7 (Official) for x86_64 installed via Mageia-7-x86_64-DVD.iso


    --- MBSE BBS v1.0.7.13 (GNU/Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)