Bash Scripting on Linux (The Complete Guide) Class 17 - Backup Script

Поделиться
HTML-код
  • Опубликовано: 8 фев 2025

Комментарии • 70

  • @LilaHikes
    @LilaHikes 28 дней назад +1

    2 years later - First I want to say this has been an excellent series. I learned so much and your teaching style and pacing are perfect. If I were to change one (or add) one thing, it would be to assign a problem/exercise after each new concept, each exercise building upon what's been learned up to that point.
    Example: _Create a script that does x. Now create a script that does xy. Now create a script that does xyz._
    I've found information sticks a lot better when you're forced to exercise your brain to solve a problem rather than just playing around with commands.
    Again, thanks. This course has been great.

  • @odnankenobi
    @odnankenobi 4 месяца назад +5

    In implementing this script, some will notice that incremental backups start to become recursive, i.e. the files in the dated folders will be created one inside the other in a recursive pattern, which is not what we want. I was utterly confused by this until I found this sentence in the manual:
    > Note that if you specify a relative path, the backup directory will be relative to the destination directory, so you probably want to specify either an absolute path or a path that starts with
    "../". If an rsync daemon is the receiver, the backup dir cannot go outside the module's path hierarchy, so take extra care not to delete it or copy into it.
    which then made total perfect sense

  • @musicluver98765
    @musicluver98765 Год назад +7

    Great series, I did a couple of Udemy classes for this. But I liked the way you broke down each line and explained it. Making it simple is the hardest job for a teacher. You nailed it!! Thank you.

  • @JamesHandley-d6b
    @JamesHandley-d6b Год назад +2

    completed the series. Very well done, and the length of each video made it very easy to find things that I needed to refresh on. Great job and thanks!

  • @yungmuda414
    @yungmuda414 Год назад +5

    Thanks jay. This is a well put together series. I learned Python about 1 year ago and now I can see why Bash is powerful while needing to script in the Linux environment.

    • @whyYUbee
      @whyYUbee 8 месяцев назад +1

      Same! Somehow I was bothered by Python and it did not excite me, even though the syntax is fairly simple, but once things get complicated, I just couldn't get myself to write in Python 😂. Bash on the other hand is smooth, fun, and I easily understand even the complex scripting.

  • @Er_IT_prashantjha
    @Er_IT_prashantjha 6 месяцев назад +3

    With this I have done with linux series, Thank you so much Sir 🙏 Regards from India 🇮🇳.

  • @busdriver1261
    @busdriver1261 2 года назад +7

    Great series - thanks Jay 👍
    An extra test you could include in the backup script is the validity of the directory being backed up in $1 i.e. bomb out with a exit code in case the input directory doesn't exist.

  • @monty_2969
    @monty_2969 8 месяцев назад

    Thanks

  • @prcmmd
    @prcmmd 5 месяцев назад

    just now i finished the course and it was really really helpful for me i learned a lot about bash scripting
    thanks for all the effort and sevrices❤

  • @sridharramalingam329
    @sridharramalingam329 Год назад

    Thanks!

  • @sohaibkhan1395
    @sohaibkhan1395 4 месяца назад

    I have completed the series, it was really helpful. Thanks a lot Jay!

  • @gabrielgodoy7846
    @gabrielgodoy7846 Год назад +1

    Nice series!! Thank you so much Jat for sharing your knowlogy

  • @Ekte_Sjakie-tr2qb
    @Ekte_Sjakie-tr2qb Год назад +1

    Thank you so much, been speed running this and it's been very very helpful !!!

  • @jonathanrider4417
    @jonathanrider4417 2 года назад +2

    Great stuff Jay! I would like for you to include storing the backups remotely; I have succeeded in doing this but had some difficulty. Also, it seems that rsync will only process files that the user owns - maybe that goes without saying.

  • @chromerims
    @chromerims Год назад

    *rsync -b and --backup-dir flags* (6:03) . . . Cool! Thank you, Jay/LLTV 👍
    I may update my rsync scripts to use those flags.
    Kindest regards, neighbours and friends.
    P.S. The / slash (or no slash) at the end of the destination's directory can be tricky. Your rsync script handles it nicely.

  • @harryman01
    @harryman01 2 года назад +2

    Thank you for the videos , those are a great source of knowledge

  • @Lyunpaw
    @Lyunpaw 2 года назад +1

    Love these episodes.

  • @skmplanet9591
    @skmplanet9591 Год назад

    Superb tutorial videos. Please continue your great work.

  • @MohamedSayed-bl5ww
    @MohamedSayed-bl5ww 2 месяца назад

    that is a great course , Thank you.

  • @ahmedismail8389
    @ahmedismail8389 11 месяцев назад

    Thanks Jay. You have been very helpful

  • @EliteBuildingCompany
    @EliteBuildingCompany Год назад

    Excellent series, thanks you so much sir.

  • @loren683
    @loren683 9 месяцев назад

    thank you very much ! great series :)

  • @hennadiikasian4389
    @hennadiikasian4389 Год назад

    Great lessons. Thank you! I would like to see a bit more lessons with shifting arguments in bash and background jobs. Apart from that I think great idea would be to have some kind of recap video just to refresh your knowledge around bash scripting.

  • @RyuBateson218
    @RyuBateson218 Год назад +10

    Why do you only have 2 dad jokes in your picture folder?

  • @k.chriscaldwell4141
    @k.chriscaldwell4141 3 месяца назад

    Thank you.

  • @oussamaboukoutaya8702
    @oussamaboukoutaya8702 Год назад

    You are great Jay, Thank you

  • @marlyin666
    @marlyin666 4 месяца назад

    thank you

  • @RykerFreegeld
    @RykerFreegeld Год назад +1

    Up to this point, it was so nice and easy.....😂 Great course though: 10/10. Thanks!

  • @anandbapat4706
    @anandbapat4706 2 года назад

    Amazing series

  • @SMARTWAYISABETTERWAY
    @SMARTWAYISABETTERWAY 2 года назад

    Great video, very informative.

  • @yoaqueem
    @yoaqueem Год назад +1

    Great series.
    Unless the "backup" directory exist before running the rsync command, rsyncs call to mkdir fails. It seems mkdir have a problem creating the parent folder "backup" to "current", unless receiving the option "-p".

  • @AndreyZloy
    @AndreyZloy Год назад

    Thank you

  • @claus-kaldeich
    @claus-kaldeich 2 года назад

    VERY GOOD! Excellent!!

  • @EdwinJimenez-i5n
    @EdwinJimenez-i5n 24 дня назад

    Very nice guy.

  • @random-drops
    @random-drops Год назад

    The date is the ISO date format. I wish everyone uses this format for date one day.

  • @guilherme5094
    @guilherme5094 2 года назад

    👍👍Thanks!

  • @okomazubuike9032
    @okomazubuike9032 Год назад

    Super great

  • @abdullahmanzoor8825
    @abdullahmanzoor8825 Год назад

    Thank you so much JAY...I would like to ask the seniors or expersts..after learning to this extent can we apply for a scripting job or what level is this which we can claim?

    • @whyYUbee
      @whyYUbee 8 месяцев назад

      To apply for a job relevant with scripting, I think you need plenty of examples that you can apply your knowledge to real life scenarios. Create automation scripts and present them on git or maybe write a blog that will present your work. Employers are not interested in which course or training you chose and went through but what you can make out of it and give them a proof.

  • @dragsterbixing2584
    @dragsterbixing2584 Год назад

    It would have been great if you had also included the pre requisites for this video or the course video somewhere so I can look them once

  • @darkknight32920
    @darkknight32920 Год назад +1

    Possibly naive question, but isn't $(which rsync) interchangeable with rsync? If it's not found in PATH, which rsync shouldn't give anything anyway, right?

    • @alyelsharkawy5907
      @alyelsharkawy5907 Год назад

      he said it is best practice to include the full path to commands used

  • @clivewi9103
    @clivewi9103 Год назад

    A good starting script, would have been helpful to include subdirectories, and append the directory been backed up so /current/pictures etc.

  • @mishelandalexphotography
    @mishelandalexphotography 2 года назад +2

    Hello! I have a couple of questions, If I may. 1. We turned on the -v option of rsync, but I didn't got any output of the command, neither did you. 2. In the argument to for rsync, we specified the "current_date" variable to name the subfolder of "current" folder, but I think it not did it... I'm sorry, if I'm wrong, feel free to correct me. Great videos though, I've learned and still learning a lot from you! Thanks!
    P.S. For question 2: I watched the video again and now it makes sense :) Sorry!

    • @stephan4921
      @stephan4921 2 года назад +2

      The output is redirected to a file with the ">>" operator.

  • @romikonlinepotapenko3475
    @romikonlinepotapenko3475 Год назад

    Could you, please, explain what does 2>&1 mean? I guess we're redirecting standard error to standard output, but why are we writing it like this? Looks weird. In one of the previous classes of this series you told that we can address both standard error and standard output and send them to the null device like this:
    if ! command -v rsync >& /dev/null
    My question is what's the difference? Is my syntax also correct?

    • @whyYUbee
      @whyYUbee 8 месяцев назад

      2>&1 redirects stderr to the same destination as stdout. I hope that helps!

    • @buntat3975
      @buntat3975 5 месяцев назад

      Both methods perform the same thing. It's a matter of preference.

  • @toromac9786
    @toromac9786 2 года назад

    It would be good to add some compression options in here too

  • @NavinKumar-wq9xb
    @NavinKumar-wq9xb 2 года назад

    Is there any way to return to a particular directory after execution of a perl script?
    Eg:
    I am running perl script in bin/a/ directory.
    After completion of the script ,when returning to terminal it should automatically reach bin/a/b/c/d/ directory

  • @davestorm6718
    @davestorm6718 11 месяцев назад

    Everything worked, except this backup script - which worked the first time, but kept getting rsync error: error in file IO (code 11) at rsync.c(739) the second time I ran it. Never could figure out what the problem was, but a clue is that, if I touched any file, then the error began (acting like the file is still open?).

    • @Your-nj5mz
      @Your-nj5mz 11 месяцев назад

      Once you follow command touch Picture\theimage.png that you want tell that been modified
      You need to type:
      ./backup.sh Pictures/ backup
      Not :
      ./backup.sh Pictures/ backup/

  • @fictitiousnightmares
    @fictitiousnightmares 2 года назад

    I tried to make an rsync backup script previously but couldn't figure out how to exclude all hidden folders/files as nothing worked for me. The reason I don't use it is because it tries to back up all my steam games and every other thing in hidden folders when all I want is to backup my damned home directly that is NOT hidden. So it takes up a lot of space it shouldn't, takes a lot more time to backup, and taxes my system while backing up stuff I don't need backed up. Would be nice to be able to finally figure out how to do a backup, have it compressed (tar.gz) and not include all the hidden files so I could have it scheduled, but until then I manually do my backups.

  • @gonets7868
    @gonets7868 Год назад

    Anyone knows what command -v stands for ?

  • @HenriqueAbrantesVitoi
    @HenriqueAbrantesVitoi 2 года назад +1

    With `$(which rsync)` you still have the same security risk of potentially running a malicious command, right?

    • @LinuxEssentials79
      @LinuxEssentials79 2 года назад +1

      There is less risk that way, because which command will give you the exact path of the command in your system. In other words, it won't run a different script or command with the same name.

    • @deprimarvin5382
      @deprimarvin5382 2 года назад +2

      @@LinuxEssentials79 I don't think that this is right.
      According to the man page of "which" it prints to stdout the full path of the executables that would have been executed when this argument had been entered at the shell prompt. It does this by searching for an executable or script in the directories listed in the environment variable PATH using the same algorithm as bash.
      So I would agree with Henrique Vitol.
      P.S. I just tested it:
      I created a script called /usr/local/bin/rsync and made it executable.
      "/usr/local/bin" comes before "/usr/bin" in my $PATH.
      "which rsync" printed "/usr/local/bin/rsync".

    • @LinuxEssentials79
      @LinuxEssentials79 2 года назад +2

      @@deprimarvin5382 OK I don't believe that it's so easy to exist so many possibilities e.g. to exist a third-party script with the same name in path included in PATH variable. But if you want to be sure, I believe you can make a control statement in your script to run the specific binary or include always the correct full path of each binary.

  • @Alpha_Sadigh
    @Alpha_Sadigh Год назад

    ☯🙏
    Backup.

  • @Lyunpaw
    @Lyunpaw 2 года назад

    %F would be a simple way to get that same date format.

  • @anjanbora7943
    @anjanbora7943 2 года назад +2

    My bash script created this for u ---> 💋

  • @HenriqueAbrantesVitoi
    @HenriqueAbrantesVitoi 2 года назад

    Any reason for using `> file 2>&1` instead of `&> file` ?

    • @LinuxEssentials79
      @LinuxEssentials79 2 года назад +3

      "> /dev/null" that redirects standard output to /dev/null (as it doesn't refer 1 or 2, it's going to include only standard output which is the default). "2>&1" this will redirect standard error to be included into standard output, but standard output was redirected to /dev/null. So both (standard output and standard error) redirected to /dev/null, which can be done more clearly by "&> /dev/null", as Jay describes it in Data Streams video in bash scripting series.

    • @LinuxCloud79
      @LinuxCloud79 2 года назад +1

      This is the appropriate expression to combine standard output with standard error.

    • @gonets7868
      @gonets7868 Год назад

      @@LinuxEssentials79 what command -v stands for ?

  • @case_2
    @case_2 Год назад

    some not good problems😂😂😂