script need
Hi,
Can anyone tel me how to make folder to create tar.gz script with date For example : I have one foder in my server path /home/data/. In side this folder I have lots of folder. Now I want to create each folder in side /home/data to make tar.gz format and stored some other path like /root/data with date using linux script. For backup purpose . my English very bad please. Thanks |
Here is an example (if I understand you properly).
1. Open text editor and create script, for example, save as:mybackup.sh (inside your /home/data/) 2. Put this inside Code:
#!/bin/sh Code:
$ chown -R root:root mybackup.sh Code:
$ chmod +x mybackup.sh Code:
$ ./mybackup.sh Code:
$ crontab -e Code:
10 23 * * * /home/data/mybackup.sh 10 (minutes) 23 (hours) * (every day) * (every week) * (every month) it may be: minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), command |
Quote:
Hi Thanks for the reply. My need is lot of websites directory contains on the directory like /home/sites/. so inside this path lot of websites directorys stored. now I want to make that each directory backup with samename to any other path.like backup folder makes with tar.gz format. this is i want. i think u understand. Thanks once again |
If I understand what you're trying to -- in /home/data you have sub-directories, say
Code:
/home/data Code:
/root/data Code:
cd /home/data That would be the simplest way; you will have one archive file containing every sub-directory. Keep in mind that you can extract only what you want from a tar archive; i.e., you could extract dir01 from a complete archive as above without extracting anything else. A little more complicated way is to archive the individual directories semi-manually Code:
#!/bin/sh We'd really like to do this without having to manually list the individual directories, so let's use the ls utility to list them and a little shell magic to get only what we need Code:
#!/bin/sh I would recommend that you use the first method -- you'll only have one dated archive to deal with and you'll be able to extract all of it or only parts that you want. The other methods give you a large number of archive files to deal with and that may not be desirable as time goes on. Hope this helps some. |
Yes, good scripts here.
Another way to accomplish the same is using some tool as backup-manager After installation, there is a config file, /etc/backup-manager.conf (if I remember correctly) and you can choose easily which directory to backup and time to live (how many days/weeks will this backup exist). Good way the save the storage place, otherwise, in a couple of weeks or months you may have a large data. Same tools may do backup of database, as MySQL, also, you may pipe some command if needed etc. Backup manager is run on desirable time, again as cron job. Also, it may copy data on another server via ssh or ftp. Very easy to customize, I think it could be suitable for this purpose. |
All times are GMT -5. The time now is 12:32 AM. |