backup script
Hi all
I'm trying to create a back up script to back up my httpd_conf file. how ever when the cron runs it works ok but the file ends up been 350 meg in size. can any one tell me where I went wrong please My bash script Code:
#!/bin/bash /Downloads/scripts/httpd_backup.sh: line 9: cd: /etc/httpd/conf/httpd_config: No such file or directory TT |
cd /etc/httpd/conf/httpd.conf(it is a file, not folder)
you can't 'cd' to here, so you will remain at current directory tar -zcf /Downloads/httpd_backup.sh.tar.gz . since you not inside the /etc/httpd/conf folder but remain at home directory, it won't backup the file for you. What it do is backup the entire home directory for you(maybe root or your home directory) so, you can change to: #!/bin/bash # this file is an automated backup script, httpd_backup.sh. # this backs up my httpd config file. # cron is ( 45 * * * * /Downloads/scripts/httpd_backup.sh ) # what directory or file to back up cd /etc/httpd/conf # path to back up folder tar -zcf /Downloads/httpd_backup.sh.tar.gz . Ks |
Actually, it's a better practice to check if the "cd" works.
So, do something like: Code:
#!/bin/bash Alternatively, you could just add the file(s) to be tar'ed at the end of the tar command. This means you don't have to do a "cd" at all. Tar also has an option to specify a file that contains a list of files to be tar'red. Maybe useful for you too. |
Change your script to something like this, which will timestamp the backup:
Code:
#!/bin/bash |
Quote:
|
Quote:
so what your saying is there's no point in backing up one file TT |
There is a point in backing up one file, if it's an important one, but only if that file changes regularly (ie daily, weekly,...).
If it doesn't, you can create just one backup copy (for recovery later on), and install some file integrity tools like samhain, aide or tripwire. They are designed to detect (and prevent) illegal changes to critical system files. If it does change regularly, you should adapt your backup frequency to match the change frequency. There's no point in taking daily backups if the file only changes once a month, right? |
All times are GMT -5. The time now is 06:28 AM. |