Easy rsync Backup with tar and cron (daily, weekly, monthly)

Поділитися
Вставка
  • Опубліковано 28 бер 2021
  • Lean how to use rsync, tar, and cron to setup a daily, weekly, and monthly backup on Linux. In this tutorial, we will backup a WordPress website, but this script can be modified to backup any directory or files.
    Code snippets and more at tonyteaches.tech/rsync-backup...
    Check out my vlog channel ‪@TonyFlorida‬
    #rsync #cron #tar #backup #crontab #cronjob
  • Навчання та стиль

КОМЕНТАРІ • 95

  • @petewarby7158
    @petewarby7158 11 місяців тому +3

    I've spent so long looking for some of the contents of this tutorial online and found it here in one place. 2nd of your videos that I've found that have absolutely NAILED what I needed to know. Awesome tutorial, thank you.

  • @VANTYCSolutions
    @VANTYCSolutions 8 місяців тому

    Thank you so much, the best 22 minutes invested.

  • @nwdsc
    @nwdsc 8 місяців тому +1

    Great video. I used this for many months but recently wrote a new script. I just have one script rather than three. In that script it runs the daily every day and then uses if-then to check if it's Friday, it COPIES the day file to the weekly folder. If it's the first day of the month, then it copies the day file to the monthly folder. That way you don't run the whole archive three separate times and only one cron job. The rest is totally based on your tutorial. Thanks so much.

  • @adooken1019
    @adooken1019 11 місяців тому

    This is gold. Amazing presentation of information ! You would make a great teacher

    • @TonyTeachesTech
      @TonyTeachesTech  11 місяців тому +1

      Glad it was helpful! Subscribe if you haven't already done so 🙏

  • @seenivasantamilmani9944
    @seenivasantamilmani9944 2 місяці тому

    Awesome man❤... Really helpful

  • @qwarlockz8017
    @qwarlockz8017 3 роки тому

    Really nice video covering useful simple scripting! Sweet!

  • @fedepetit
    @fedepetit 2 роки тому +1

    Very nice tutorial, specially for those of us who know little about Linux. This method implies you have enough space in the source to make the compressed backups to transfer to destination.

  • @lakshmisowjanya9492
    @lakshmisowjanya9492 2 роки тому

    Excellent tutorial
    Exactly matched to my scenario
    Thank you so much

  • @frankgarcia4644
    @frankgarcia4644 5 місяців тому

    Awesome video. Thank you for your explanations and details.

  • @jeucedahn
    @jeucedahn 11 місяців тому

    Very well explain video!! Thanks for sharing!

  • @laci272
    @laci272 3 роки тому

    Great video. I did need it. Thanks for doing the research (and for the videos)

  • @mdara_jigga
    @mdara_jigga Рік тому

    great video. excellent explanation

  • @MadRobDestroyer
    @MadRobDestroyer 9 місяців тому

    Amazing thank you for this. Very good explanations.

  • @angelozou3914
    @angelozou3914 Рік тому

    Thank you for your video. Usefully.

  • @mason8714
    @mason8714 Рік тому

    great video! perfect for what i need - also subscribed

  • @jehad2322
    @jehad2322 Рік тому

    Thank you for a great tutorial.

  • @ldinoc8087
    @ldinoc8087 3 роки тому

    Great job and best explanation

  • @AmitAnand14
    @AmitAnand14 2 роки тому

    Really what I was looking for......👍

  • @mattd4559
    @mattd4559 Місяць тому

    Great video, thanks for your help

  • @bappelzoller1817
    @bappelzoller1817 2 роки тому

    Very nice! Your a great teacher ~~ easy to follow :-) It helped me Thank you

  • @N0AGI
    @N0AGI 2 роки тому

    well done - thanks for sharing.

  • @mohammedshalash7842
    @mohammedshalash7842 14 днів тому

    Many THANKS

  • @isaargentina4495
    @isaargentina4495 Рік тому

    Owesome!, you really helped me. Thank you so much.

  • @chromerims
    @chromerims 11 місяців тому +1

    Nice video on tar, rsync and crontab 👍
    I shall try the script but also experimenting with piping each of the commands into grep error and further piping into either touch error or cat > error-$(date +%Y%m%d), all in order to gate the steps and log errors.
    Also I shall experiment with creating tar.gz files onto a labile ram disk. Maybe better for speed and wear. Dunno.
    Kindest regards, friends and neighbours.

  • @picnicsinspace198
    @picnicsinspace198 2 роки тому

    Thank you :) youre awesome

  • @viveknayak
    @viveknayak 3 роки тому

    thanks for the date command, I used to do that manually before

  • @heel57
    @heel57 Рік тому

    thanks for offering this video. Would have been perfect if you also included the restore process.

  • @raul230285
    @raul230285 2 роки тому

    Excelent..!! saludos desde Perú..!! Theacher

  • @mosesotieno1629
    @mosesotieno1629 Рік тому

    Clearly explained! Thanks! Any idea backing up to Google drive?

  • @clivewi9103
    @clivewi9103 2 роки тому +1

    A good video; I was wondering why you used three scripts when one would have done the job, and you could have avoided the problem of the rsync command running before tar had completed its task? I was also wondering because you have created the three scripts why you didn't move the scripts into the crontab directory structure where jobs are run daily etc. I agree with Anders A you really need some logging so perhaps make a follow on video to show how you add logging into the script.

  • @jamesmichaels4209
    @jamesmichaels4209 2 роки тому

    very nice thanks

  • @sjgsteve21
    @sjgsteve21 Рік тому +2

    What if you only want to backup changes to your directory. Presumably tar is not what you need to use for this? Eg if I want to backup my entire Plex library for redundancy purposes.

  • @pankajdeshmukh6565
    @pankajdeshmukh6565 3 роки тому

    Thanks bro

  • @HamzaTrichi-yt1zz
    @HamzaTrichi-yt1zz Рік тому +1

    Shuouldn't you execute the rsync command at 01:00 AM for example, to make sure that all the backups are made before moving them?

  • @stlouisphotography
    @stlouisphotography 2 роки тому

    Cool!

  • @actng
    @actng Рік тому

    how do i take an image of the entire linux server and restore it later?

  • @JunyueWang-vc9we
    @JunyueWang-vc9we Рік тому

    Great Great videos! actually how to include the password option in script without using public key? Appreciate in advance!!

  • @mauwiks
    @mauwiks 2 роки тому

    can you explain the options

  • @mauwiks
    @mauwiks 2 роки тому

    how about we make a filename as the username of the account + date

  • @louisgamor
    @louisgamor 3 роки тому

    Awesome video....loved every bit of it😍👍
    Is there any reason why there is a space between the 'var/www' and the 'html' directories?

    • @TonyTeachesTech
      @TonyTeachesTech  3 роки тому +3

      Oh for this command? tar -zcf /home/tony/backup/monthly/backup-$(date +%Y%m%d).tar.gz -C /var/www/ html
      The -C flag means to change to the /var/www directory and the html argument is the directory that we want to archive

    • @louisgamor
      @louisgamor 3 роки тому

      @@TonyTeachesTech Awesome...thanks a million 🤗

  • @angeltysonswe
    @angeltysonswe 2 роки тому +1

    Is there any reason as to why run multiple tar arguments for monthly and weekly?
    Couldn't they just include an copy or hardlink command to the tar file that the daily script creates at that point? And in so decreasing the harddrive usage and decreasing CPU usage as you don't have to compress your files so many times?

    • @TonyTeachesTech
      @TonyTeachesTech  2 роки тому +1

      That sounds like a valid point. In no way was I considering efficiency in this tutorial. Thanks!

    • @SchwarzerCorsaR
      @SchwarzerCorsaR Рік тому

      If you think of huge amounts of data, it might well happen that you‘re running out of allocated time for backuping. I modified you‘re (else great!) tutorial to just copy once a week / month / year. A link wouldn‘t do the trick as the intention is to maintain older backup versions.

  • @andreasmoller732
    @andreasmoller732 2 роки тому

    Hello.
    when I use find delete command +3 it does not want to delete any files but when I use -3 it deletes new files ... I have files in the folder that are older than 3 days but they do not work ....
    find /mnt/exe/backups/nextcloud-db/* -mtime +3 -delete

    • @TonyTeachesTech
      @TonyTeachesTech  2 роки тому

      I think you understand this, but just to make sure the +/- depends on when the files were created i.e. timestamp

  • @jeremiahbullfrog9288
    @jeremiahbullfrog9288 Рік тому

    I never remember about the -C tar flag... what a handy option.

    • @jeremiahbullfrog9288
      @jeremiahbullfrog9288 Рік тому

      Never knew that you could so easily cull old files with a simple find option

    • @jeremiahbullfrog9288
      @jeremiahbullfrog9288 Рік тому

      Not a fan of blanket passwordless root access via ssh keys.. will you address this? 9 more minutes, maybe that'll be in part 2

    • @jeremiahbullfrog9288
      @jeremiahbullfrog9288 Рік тому

      I don't understand the bit about deleting and then "oops no we actually need that because [unintelligible]"

    • @jeremiahbullfrog9288
      @jeremiahbullfrog9288 Рік тому

      I love the stream-of-consciousness motif where you show the mistakes like "backup" vs "backups" and checking in realtime whether the cron job is calling the correct path.

    • @jeremiahbullfrog9288
      @jeremiahbullfrog9288 Рік тому

      Looks like a workable backup solution with minimal fuss, thanks for sharing your expertise. Subscribe.

  • @chrisxu6491
    @chrisxu6491 Рік тому

    What to do when tar-ing files that are owned by root? I got many "permission denied".

    • @shallex5744
      @shallex5744 Рік тому

      use root permission when tarring them

  • @jeytis72
    @jeytis72 Рік тому

    "Execute the daily backup script everyday at 12:15 AM" - What if I want to backup at 8:30 PM for example. Thanks

  • @DroidRaxx
    @DroidRaxx 3 роки тому

    Hello,
    What about the database backup?

    • @TonyTeachesTech
      @TonyTeachesTech  3 роки тому

      You can look here ua-cam.com/video/_zu9ss2RX-0/v-deo.html

  • @KuroroLucifer21
    @KuroroLucifer21 Рік тому

    Hi there, i am trying a whole week now to get rsnapshot running. Please, can u give an advice or recommendation for a tutorial for linux beginners? We are running ubuntu server, no problem with creating samba servers or webserver that serves us well, but until now - and after a dozen very different tutorials online (and everyone got so much differences) - we are just a few days before fucking the whole linux story and running everything with windows until ransomeware take us out. Before you recommend us to count the days until it happens and we deserve that - pleeeease reflect that out there, there are many small NGO's besides us (like aids help, abortion help, transexual help and other ngo's with just a few people who are really helpless and will shut down one after another in those days :( )

  • @mindtheyoutubegap
    @mindtheyoutubegap 3 роки тому

    Andway to have the destination to be Google Drive?

  • @laci272
    @laci272 3 роки тому

    Tony, the contact form on your site is broken. "There was an error trying to send your message. Please try again later."

    • @TonyTeachesTech
      @TonyTeachesTech  3 роки тому

      I'm not seeing this issue. What browser are you using?

    • @laci272
      @laci272 3 роки тому

      @@TonyTeachesTech I've tried in Brave and Firefox and Opera:) (Opera is default, no plugins, no changes)

    • @TonyTeachesTech
      @TonyTeachesTech  3 роки тому

      @@laci272 Thanks for letting me know. I'm not sure what's going on here. It's working for me on Chrome, Firefox, and Opera.
      Unfortunately there's no log file that I can check to debug.
      I changed the error message though to include my email address as an alternative method of contact. Please try again to see if that shows up for you and then feel free to contact me that way.

    • @laci272
      @laci272 3 роки тому

      @@TonyTeachesTech i still get the old message:) There was an error trying to send your message. Please try again later.
      wait.. i'm on tonyteaches.tech .. are we talking about the same site?

    • @TonyTeachesTech
      @TonyTeachesTech  3 роки тому

      @@laci272 I really apologize. I'm not sure what's going on here. Another way to get in contact with me directly is to get my email on my UA-cam about page ua-cam.com/channels/WPJwoVXJhv0-ucr3pUs1dA.htmlabout

  • @philipnwosu3691
    @philipnwosu3691 2 роки тому

    Put Caveat on the --delete command

  • @keithmiller9665
    @keithmiller9665 3 роки тому +1

    First of all thanks for video, very useful. It does however need editing as in several places you either make a mistake or get a bit lost. So it would definitely benefit from an hour or two of editing. Still a good video though. Thank You !

  • @surfreadjumpsleep
    @surfreadjumpsleep 3 роки тому

    Should work on a mac also, correct?

    • @TonyTeachesTech
      @TonyTeachesTech  3 роки тому

      Yeah. Only thing is a cron would require your mac to be on at the time it executes.

  • @alertshake8965
    @alertshake8965 2 роки тому +1

    Borg is a better solution. Look for Borg backup.