Noob here, just saying hi.

Discussion in 'Linux Beginners' started by Chris_UK, Aug 21, 2021.

  1. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    Well okay I am not, you would think somebody who is reasonably knowledgeable in the what's and what nots of web developing would know a thing or two about what really not to do.

    So, I am here and I am demoting myself to Linux noob status!

    Why you might ask. Well, I shall tell you a story all about how I just turn into a noob in one sweet command line incident.

    ## SUMMARY
    Move /home/user to partition on second drive, check successful, remove remnants from old home, mount now home.

    Sounds easy doesn't? And it is, it really really is. EXCEPT!
    Code:
    mv /home/user/* /media/mount
    
    View old home, just to check few stragglers (ownership issues)
    Code:
    cp -r /home/user/* /media/mount
    
    Success, copied. remove the stragglers
    press up arrow > home > change cp to rm add -f (ownership issues)
    Code:
    rm -f /home/user/* /media/mount
    
    Forget that you just did both a copy and a move and that you are only removing /home/user/*, DO NOT look at the command line.. No, don't you do it just hit enter, you are an experienced linux user!!!
    Code:
    ENTER
    
    The moment the key touches base, you glance at the command line, your eyes lock onto the last command you ran, then it dawns on you. You REALLY did not mean to delete all of the files that you just moved to your new home directory. You check in vain that you didn't all the while knowing you did.

    You panic, you call yourself stupid names you don't know what to do, You hit google, the best friend you ever could have right now. You browse, you try a few things, you read of testdisk, yes, this will do what I need... No not doing it, how is it finding 1.5tb / 1.3tb on a 500gb disk. Help, no, something is very very wrong with this..
    Back to google.. You have used dd once before but it scared the crap out of you so you already skipped past those result, now it seems the only option. You man up, you are already in about as bad a place as you can be. You hit the drive with DD. You know the data just came from your ssd, you will just sent it back. No worries.
    12 minutes later, Gnome message - your drive is almost full.... WHAT?

    You forgot its a partition image that dd is creating, your 90gb space left on your SSD is not cutting the mustard. 500gb image will just not go. You kill dd. Okay new drive in the morning I will just go to bed.

    And when you are just about ready to call it a night you remember you cant turn off the computer because your home is gone.

    The only saving grace here is that all of the hidden files in my home directory were missed, they lived to allow me to come here and post this cautionary tale but probably worse, I would have missed them too and wondered where all my settings went on reboot.

    Like I said.. NOOOOOOOOOB!

    So, I am going out at 10AM to buy an external HDD

    I want to cry. but Im a big boy. I will walk it off. Breath in, and breath out, in again, out again.

    Hi, I am chris, I am noob and this evening I made an error that caused a cascade failure in my logical reasoning.

    PS please do not follow my example unless you have a spare disk at least equal the size of the hdd you moved to.

    PS: I used to wonder how somebody might do something so stupid, I recall it was one of the first warnings I read when I started out in linux some 20 years ago.

    Beware of rm -f its a system killer when done wrong.

    That was the warning, I remember it as clear as if it were yesterday. Distinctly I recall thinking "what sort of idiot would do something like that".


    Hi, I am noob. #IWantThatUsername
     
    Last edited: Aug 21, 2021
    Th0m likes this.
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Don't fix what is not really broken.
     
    Chris_UK likes this.
  3. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    Exactly, I was just moving home off the SSD because its been getting a lot of activity of late. I figured I could protect the drive a little. extend its life.

    @ahrasis
    Can a username be changed here in the forum? I think i might like I Am NoOb
     
    Last edited: Aug 21, 2021
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    I am not sure about that in here but in all forum softwares administrator can always do that for you or any of its staff that has similar permission or members are given permission to change their own username.

    In some forum softwares, a display name can be used as well but I don't see any of that options in here meaning that either they are turned off or they are not available by default except for forum administrators.
     
  5. Chris_UK

    Chris_UK Active Member HowtoForge Supporter


    That's okay I have slept since then and decided better of it. Anyway data recovery is not going well ddrescue gave me a blank image. I am back to testdisk with a deep scan currently running. I can only hope that the drive I bought will be large enough.
     
  6. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    Well, the data recovery went badly. Nothing was saved. Back to square one.

    So, next steps.
    1. Automate backups.
    2. Download all website data
    3. Backup
    4. Download all of my accounts
    5. Backup
    6. Download anything else that is recoverable online.
    7. Backup
    8. Spend the next few months looking for my suppliers contacts as I happen to need them
    9. Backup
    10. Backup
    11. Backup
    12. Backup
    13. Backup
    14. Backup
    15. Backup
    16. Backup
    17. Backup
    18. Backup
    19. Backup
    20. Backup
      .............................................................................BACKUP
    Yeah, I am a little mad at myself right now.
     
  7. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    You should first try to restore your ISPConfig server using following the relevant PST and restoring whatever backups you have.
     
  8. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    It's okay ahrasis, this isn't a server related issue. Linux yes, ISPConfig, no. Funnily enough, those I have backups of.
    Just my personal computer that I work from affected. You know this would never happen in windows :p. Anyways, I have gotten the important stuff, well what I have been able to remember so far from various online sources that were not technically backups but as it happened turned out to be a good alternative.

    The main and only thing that I really care about from what was lost, I have been able to rebuild my business accounts because I only keep the paypal transactions. as its the only way I accept payments at the moment so that's certainly been helpful. Honestly I would not like to have that conversation with the tax man. Hi, erm.. yeah err you know its time for me to submit my return.. Well, erm.. can i just say... I am NooB. Luckily I don't need to.

    A few other things that I deemed important I have gotten back. But to be totally honest, its kinda nice not having a mass of files in my home directory staring at me each time I go looking for something, its just a matter now of remembering not to go looking because its not there lol. That said, I would have liked to recover some (actually all) of it. Alas, thats not meant to be so..

    I am NooB o_O
     
  9. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Another good way is to backup somewhere else like in gDrive. You just need to remember creating auto backup to it before you start messing up with your linux desktop or server.
     
    Chris_UK likes this.
  10. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    I have a back up right now to the drive I bought yesterday. not ideal but safe.
    I am probably going to add a linux backup nas of some sort, I will also write a small script to fire off rsync on system boot.

    Probably not Ideal doing the sync at boot, but being a computer rather than a server its not always on, so on boot is probably the best solution because its the only way to guarantee that the machine is on at the time set other than leaving the computer on 24/7. I will just have to figure a way to prevent it running if I reboot. Probably a last run timestamp in a file would solve that.
     
  11. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Have you considered BackupPC https://backuppc.github.io/backuppc/ ? It is available in most Linux distributions.
    Provided you check the BackupPC host is running, it takes backups of client hosts. It is enough if the client hosts are occasionally up enough time that the backup runs to completion. And BackupPC does incremental backups so it does not take long.
    Howtoforge has two tutorials on installing and using BackupPC. Would there be intrerest on me writing a new tutorial? It might be needed, since it is not uncommon to read about big problems on these forums, where the problem would be much smaller if there were backups.
     
    Chris_UK likes this.
  12. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    I was just looking into rsnapshot, it was looking promising until I saw this issue: https://github.com/rsnapshot/rsnapshot/issues/279 To save you some time, the package is not in Debian Bullseye as its not maintained. Although its stable. They are looking at backporting it.

    That doesnt actually matter for me, I am using ubuntu but if it doesnt get back in then I expect it will be dropped from ubuntu at some point too.

    I will take a look at backuppc.
     
  13. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    That's what @till likes to do as it is easier to restore.
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    ahrasis likes this.
  15. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    This nas business has taken me down a veeeery deep rabbit hole.

    At this point I would consider buying one off the shelf but at the same time I am looking at bare rack cases and raspberry pi with a light weight nas os because it would I think scale better. It also seems that it may be more cost effective with the bulk of the cost coming from the drives rather than custom packaging.

    Hopefully Croydon will drop in if he has been testing.
     
  16. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    Well, this is a small script I have put together.
    I am on ubuntu 20.04, it took longer to get the notifications running than anything else.
    Code:
    #!/bin/bash
    export XDG_RUNTIME_DIR=/run/user/$(id -u)
    
    excl='rsync.ex'                               # File with list of excludes, mostly cache, trash, large/unimportant files.
    src="/home/chris/"                            # Last slash required
    dest="/media/chris/Backup"                    # Local sync (External Drive?)
    #dest='[email protected]:Computer'           # Remote sync (NAS Maybe)
    delay=4                                       # Minimum Number of hours between syncs
    
    # /etc/crontab: 0 */4 * * * chris /path/to/.rsync/rsync
    app="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/"
    now=$( date +%s )
    next=$( cat $app'rsync.next' 2> /dev/null || echo 1 )
    if [ $now -gt $next ]; then
       rsync -az --delete --exclude-from=$app$excl $src $dest
       next=$(( $now + $((60*60*$delay )) - 10 ))
       echo $next > $app'rsync.next'
       message="Backup completed at: $( date -s @$now )"
       img='format-text-bold-symbolic.svg'
    else
       message="Next backup due at: $( date -d @$next )"
       img='action-unavailable-symbolic.svg'
     
    fi
    
    
    notify-send -i "/usr/share/icons/Yaru/scalable/actions/$img"  "$message"
    
    It might not be the cleanest solution, but it works. Oh I just cleaned it up a touch too, removed the eval line, not needed and the sleep, that was a remnant of testing.

    added hourly /4 I forgot cron could do that. Might be worth rethinking this script some more.
     
    Last edited: Aug 23, 2021
  17. Chris_UK

    Chris_UK Active Member HowtoForge Supporter

    Well, this thing has taken on a life of its own. I will be setting up a git once I have it fully fleshed out.

    I already have it running backups with notifications.
    I have implemented INI style configuration (which was no fun let me tell you) and I am working on a configurations test and multi sync options.

    As rsync doesn't at this point appear to support remote to remote backups, this is where I am adding in some options:
    pull push : remote to remote with host server/computer as an intermediary, I am not dead set on this one
    multi push : backup to multiple remote servers
    multi pull : Backup multiple remotes to one source.

    I think I may have accidentally swallowed the red pill.
     

Share This Page