Linux Backup with TAR and Cron Jobs
Vložit
- čas přidán 2. 08. 2024
- Info
Level: Intermediate
Presenter: Eli the Computer Guy
Date Created: September 21, 2010
Length of Class: 35 Minutes
Tracks
Linux
Prerequisites
Introduction to Linux
Installing Linux
Basic Linux Tasks
VIM for File Editing
Navigation in Linux
Users, Groups and Permissions in Linux
Purpose of Class
This class teaches students how to backup directories using TAR, and demonstrates how to schedule tasks using Cron Jobs.
Topics Covered
Backing Up Directories with TAR
Recovering Directories with TAR
Setting Up Cron Jobs for Scheduled Tasks
Class Notes
Backup Using TAR
Backup = sudo tar --cvpzf backup.taz.gz --exclude/=directory (recursive) PATH
--c = create new file (overwrites old file)
--v = verbose
--p = preserve permissions
--z = compress
--f = filename (very important)
--exclude=DIRCECTORY is Recursive
Naming Files with time = filename-$(date +%F-%T)
Recover Files from a TAR File
Recover = sudo tar --xvpzf FILE --C /DIRECTORY
Capital -C = change to directory
-x = extract
Cron Jobs
To Edit the Crontab File = sudo cron --e (first time it will ask you your default editor)
Format = minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), command
* Wildcard for Every Minute/Day/Hour/Month?Day of Week
Example to Backup Entire Server for 1am Every Morning = 0 1 * * * sudo tar -cvpzf /backup.tar.gz --exclude=/mnt / - Věda a technologie
Eli is the first source of information when I want to learn something new or just review things I have not worked with in a while. He is clear, easy to understand and the material he uses to show you something is easy to get.
ELI IS TEACHER WHO CAN TEACH
I just went through your whole Linux course tonight, massively appreciated, very clearly presented.
Einstein said that any intelligent fool can make things bigger, more complex.
But it takes a touch of genius and lots of courage to move something in the opposite direction.
Thank You for this tutorial
Can't wait for tom to watch this so i'm watching it now... watched your whole Linux class straight and i loved it.. THANKS ALOT!
Thx Eli you are the bomb!! I've watched about 35 of your videos so far and haven't been disappointed yet, thanks for making it easy to grasp!
Thank you so much for making Linux so simple to understand. You are the best teacher ever! I watched all the 9 videos from introduction to the end, every class was very easy to understand and I would be glad to watch all your classes. You just earned a subscriber.
you are a star after this many years, no one has such a great description
Eli you have by far the best tutorials on CZcams! I've learned so much from these linux videos and I love how you focus on what matters!
what a king you are! That is how things should be explained. I run into many tutorailas that skip points that make people confusing..Thank you
Thanks Eli for your patient and clear class. I learned a lot from you.
Watching in 2022. Eleven years later this is still very useful. thank you.
Two questions:
1) How to exclude more than one path?
Like: I don't want to keep /mnt and /media and /tmp
2) How to create a backup file for more than one path?
Like: I want to create an archive file, and I want it to include /usr/share and /bin and /var/www.
BWT sir, you're awesome.
Keep do this. :)
tar -xvpzf your_backup.tar.gz --exclude={"/home/*/Downloads/","/home/*/Documents"}
Excellent Teacher I have seen in my life Since I started the school on 1978
Great instruction. Just moved a website to a dedicated server and plan on using this to perform backups. Thanks dude!
I wish I would have found you weeks ago! Thank you for explaining this down to the meaning of each character. Much appreciated!
wOw!!!!!!
I never thought I would learn Linux this fast.... 2 Days and i know hell lot of things....
.
THUMBS UP ELI !!!! U R AWESOME
you made my life a lot easier with this video.....keep posting these kind of videos...you are too good in teaching eli
Awesome job Eli! I had so much fun and boosted my confidence. Cheers!
Best Video, your narration is too good to keep track of and your recap actually makes it hard to forget! Thank you soo much! Look forward for more videos :)
Love your videos - educational while entertaing :)
Excellent Video. Thanks for helping me understand Linux a little better!
Fantastic tutorial. I am so happy that I found your channel. Keep up the great work.
Thank you kind brother. You are a gentleman and a scholar.
Eli,
Great video. Very instructional and informative to both the expert and the person just beginning. Will look forward to more tutorials.
Jeff
Thank you for the detailed explanations of it all.
Eli, you are great, nice video and presentation. I enjoy watching all of your video.
God bless you Eli! Your videos are lifesavers! Thank you ! I wish I could replace my current teacher with you.
thank you sir for your valuable videos. I learned lots of thing from basic to advance from your tutorials.
thanks a lot
Here we are, some 10 years later, and THIS is still the best way I could find to back up my Linux systems (maintaining permissions and symlinks) to a NFS mounted NAS drive and AWS S3 bucket.
Thank you for your efforts to share your knowledge to everyone who wants. These are very helpful me.
Awesome I was searching for a linux backup program .... but this is so simple ... thanks!
Best video yet, you saved my brain thank you!
OMG, Thank you. This is the one of the most useful tut
Great series...Thank you Eli.
This was so well explained. Thanks a lot ETCG.
Thanks for the video....I was struggling with this.This video helped me to solve my problem.
Excellent video again!!
thanks a lot, your lessons are very informative and useful.
Excellent tutorial series on Ubuntu Linux !
appreciate your videos lessons and logical well expressed manner 👍
thanks.. Happy to say u are my Linux teacher ..
You can backup /
If you need a bare metal backup you can just use a piece of backup software.
Eli you are a awesome teacher
Thanks a lot, you can explain amazingly simple.
Nano is an excellent editor for those finding Vim too difficult.
tq eli, u r making my life easy
Many thanks buddy. You got yourself a subscriber
thank you very much. You are a really great trainer.
Thanks a lot Eli
Yes you can, everything you can do with the server can be done with the desktop using the terminal
Awesome !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thanks for All lectures
Still so much powerful videos
I like Your Channel So much You are the best teacher i ever had !
You are amazing Guy Too bad I can't join you in real Classroom With my laptop :)
have a nice Day Greeting from Algeria
Solid overview Eli.
whole day i had struggled and got this video thank u very much , please some video of apache and mysql thanks eli
superb sir thanks for upload
Great teacher
hi Eli, I have an idea for part two of this tutorial - I intend to do backup of my system, so that once it will get corrupt (after update/upgrade), I could go back to previous working Linux before corruption of the system.
That's something I am missing in this tutorial.
BTW - your tutorials are amazing! I've seen around 20 to date and they are so easy to understand! thank you for sharing with your knowledge with us publicly. cheers!
Woow AWESOME course!
You are taking time explaining every single thing, + you are speaking at a perfect pace for a non-native English speaker
Thumb up + Subscribed
Are the 19 who disliked your video, tried it on Windows?
Great tut!
IT's very easy to understand, thanks very much.
LOL, Dang it ELI!!!
I watched this video trying to remember if its:
....--exclude=/mnt.... or
....--exclude = /mnt... with spaces
Eli: "I'm not going to exclude anything, just to make life easier..."
LOL that was funny
Great video. Question. What if you wanted to transmit that backup off site to another Linux machine on a schedule? How would you do that?
Great video...
This video helped me a lot
Thanks !!!
u make my day :) ty alot
You are awesome sir
Sir,can you please do a video on Shell scripting(Bash and Perl)?
Hey Eli I have a question, im running linux mint 19 and I was wanting to add a custom desktop environment from the web, ive already got the file and its a .tar.gz but I cant figure out how to add it
usefull...superb
thank u so much ur amazing and awsome for averyone intersted
thanks for sharing !!!
Eli, I love your tutorials and how much you simplify them. Can you make a video on red hat or Centos kick-start? i mean the distribution doesn't matter if its a Linux kick start.
There is lot more to tell about tar. t - option/switch/argument for me is the sugar when I use tar . Width a "t" option/switch/argument You can look inside tar archive :) Also its possible to extract one file after You had a look with a "t" option. About sudo - I belive Eli has configured sudo to be used without a password for certain non authoritative user to operate with system as a root. It's wrong - sudo loses the concept why it was made :) Also using sudo in cron - it's wrong for most of us, in case of Eli - as I said, I believe he has made one non authoritative user to be used without password. Also - sudo - it is not in all Linux flavours / distributions. Eli I would enchant this video course. But!!! Even for me it was great to listen - You are great orator. Good Job.
thank u
i saw ur videos
it helps mee...
thank u
Thanks, I used tar in the past for backups but couldn't do it right. All good now. Is it possible to encrypt the backups with tar?
hey eli ...gr8 job man .!!! please upload more video of servers like ftp, samba, dns, nfs. thnx alot again
Thank you !!!
All very good! Except using wordpress :-) Thank you for sharing! Just wanna add that performing the tar -c.. command is NOT adding new nor updating old files inside the tar.gz file, every time it overwrite them, just take it into consideration! Also you can recover a single file from the tar, by using the --file option.
THANKS VERY MUCH
Hi Eli. Thank you for really helpful course. Excellent presentation of the material.
thank you for this share
-p only matters on the extraction mode (tar -x). It makes no difference on create mode (tar -c).
Iv'e seen where folks recommend backing up / in Arch linux HD install from live cd being chrooted into the installed system. Is that what you do or does it only matter on Arch? Thanks for all your helpful videos!
Your awesome ....
I miss this Eli
grt job eli..
Linux has a very helpful command called "file". This command can tell you what a file contains based on the contents of the file. It can tell you that a file is a compressed file, tar file, mp3 file, python file, etc. etc. So if you do create a compressed tar file called "Bob", you can identify it years later!
It depends on what you want to compress. Video/Audio/Image files aren't really cut for compressing. Text-Files profit the most probably.
*** 5 STAR *** for you as always ...
if I type sudo tar -c in my macs terminal will it start backing up everything?? where?
nice work
You look like Guillermo from the the tv show weeds
But thanks, this is very well explained and helpfull.
Good morning, Mr. foremost of all I thank you for your excellent tutorials. So I want a proxy to block sites on Linux and if you have an idea I really need your help thank you
really helpful
Parameters can always be mixed for example ls doesn't care if you type "ls -RQ1" or "ls -1QR" :)
awesome
Is there any reason to use tar over rsync for regular backups?
Two reasons.
1) You need to archive to tape. I mean *really* need to. Not _want_ to because that's how you've always done it, but _need_ to because an rsync to disk won't cut it (because you're the NSA and archiving vast quantities of data forever so it has to be to tape).
2) You've never heard of rsync and therefore tar is the only backup tool you know of.
That's it. Those are the only two reasons, and number 2 is dubious (but appears to be why this guy is using it).
Rsync isn't just for backups. Two of the companies I've worked for used ftp (gah) to push tarballs to web servers then unpack them on the servers. And usually there were only minor changes to one or two files, but keeping track of what's changed and pushing only those files over is tedious and error-prone. But the tar-ftp-untar cycle is *slow*, especially if your company is out in the countryside with a shitty connection (pleasant working environment though). So, an hour (or two, on a bad day) to do the tar-ftp-untar thing compared to a few minutes with rsync. Because the connection was so shitty it wasn't just that the ftp part left the developer twiddling his/her thumbs for an hour, it made life difficult for everyone in the office for an hour. Those companies switched to rsync as soon as I demonstrated it to them.
And it's also good for server migrations. Prior to me coming along and teaching them about rsync, a server migration required a code freeze whilst tarballs were packed, tarballs transferred from one server to another (usually data centre to data centre, so speed was good), tarballs unpacked, new server tested. Not forgetting the mysqldump on the old server and restore on the new. That usually meant a code freeze of 3 or 4 days on all the sites on the server. With rsync it was an hour of code freeze. Yeah, transfer the lot beforehand without a freeze, because that's a lot of data and takes a while. But then freeze and rsync to catch up on changes in an hour.
The day I found rsync was the day I stopped using tar for backups. That was 16 years ago.
The way you presented Linux videos were really fantastic and it was very crystal clear.Can you share me the link if you have complete Linux Courses Videos....