Results 1 to 2 of 2
Hi all,
I am a complete newbie in Linux so pls bare with me if you find my questions stupid.
I have been tasked with doing backup for a Linux ...
- 09-09-2008 #1Just Joined!
- Join Date
- Sep 2008
- Posts
- 1
Can this be done?
Hi all,
I am a complete newbie in Linux so pls bare with me if you find my questions stupid.
I have been tasked with doing backup for a Linux Server CentOS (setup by another employee that has left the company). I have been told by my backup software agent that they do not support Linux CentOS version.
I am thinking the method should be somthing like this for the backup.
(1) Schedule a backup job every night
I am having problems with understanding whether to use 'at' or 'Crontab'. How do i create a scheduled job with so many commands? Create a batch job?
This backup job will do the folllowing:
- Backup the folder to a backup folder by date
cp -r /home/hope/files/* /home/hope/backup/ ???
I am not sure on how to create a daily folder ( use mkdir ?)
- delete the old folders (only keep 3 days old)
(2) Zip out the files
Zip /tmp/packages /var/work/packages/*
Is the above the correct command? how do i install the zip uility and what to use?
(3) Copy out the zip files to another windows server that my backup software agent will support.
I am not sure at all how to do the above
---------------------------------------------
Would appreciate any advice that i can get as i am quite stuck.
- 09-09-2008 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Yep, not only can all of that be done but it's one of the more common requests and strengths of Linux/Unix. With regards to the scheduling aspect, I would use cron and I would write a bash script to contain your 'shopping list' of the steps you wish to take. You would then schedule this script to run rather than scheduling each step individually.
There are a lot of questions to be asked, such as do you want a full snapshot everyday over the three days or would you rather just have a differential backup on top of a master backup. Also you can use tools such as rsync to keep a mirror of a directory.
When it comes to compression, I wouldn't think so literally by using zip. Although zip is already included in most distros you might considering using tar for the archive with bzip2 or gzip compression as bother are better than zip and tar itself can be used to do things such as maintain permissions etc.
Have a read through this article on rsync backups to get you started
Linux.com :: Back up like an expert with rsync
What I would suggest is reading up a little on Bash, the standard Linux shell. Certainly you will get help writing the backup script (and it should be quite straightforward) but if you were to leavie all the work to us will cause trouble for you later when you need to modify/update parameters.
Here are some examples for some of the things you asked, though by no means is this a full solution and is only to illustrate. Anything from the #hash sign onwards is a comment
This rsync command is in update mode so that it will only copy new files or files that have been modified. So if you have the same file unmodified in both source and destination directories it will be skipped to speed up the operation.Code:#!/bin/bash backupdir=$(date +%Y%m%d)-backup #defines the directory name variable with todays date; in this case 20080909-backup mkdir /home/hope/$backupdir #Creates the directory with the variable defined above in /home/hope rysnc -uav /home/hope/files/ /home/hope/$backupdir #synchronises the source and destination directory.


Reply With Quote