I need to create a script, maybe
bash, maybe just a
.sh that checks for files changes on a root directory and sub-directories of the root, and adds to a new file. The tar.gz file name should have the creation date at the end (e.g.
monitor-17.06.2013.tar.gz). I made this:
tar -zcvf /home/monitor.tar.gz /var/www/html/monitor --exclude /var/www/html/monitor/cache /var/www/html/monitor/log
and it works, but the directory
/var/www/html/monitor/log isn't omitted, the file name doesn't contain the date, and this is missing the part that adds only new or changed files because I don't know how to do it.
EDIT: clarify a bit my needs Ok, due to some comments by users here I'll try to leave exactly what I'm looking for.
Day1: 2013-06-15 Directory: /var/www/html/monitor Backup File Created: monitor-2013-06-15.tar.gz (contains all the content of /monitor folder) Day2: 2013-06-16 Directory: /var/www/html/monitor Files Changed: /var/www/html/monitor/file1.php /var/www/html/monitor/log/file2.php /var/www/html/monitor/web/file3.php Files Added: /var/www/html/monitor/index.php Backup File Created: monitor-2013-06-16.tar.gz (contains **only** the files index.php, file1.php, file2.php and file3.php) Day3: 2013-06-17 Directory: /var/www/html/monitor Files Changed: /var/www/html/monitor/index.php Backup File Created: monitor-2013-06-17.tar.gz (contains **only** the file index.php)
The first backup always will have all the content but the rest should only have the modified files and the newest files, nothing else.