--newer-mtime=$(date --date='6 months ago' +%Y%m%d)
How to format date for tar backup?
Question
So I have a bash
script that I need to run weekly but I don't know how to format the date so I can automate the script.
My script:
#!/bin/bash
tod=$(date +%F_%H%M%S)
echo "start"
echo $tod
tar --newer-mtime=20130811 -cvzf /path/to/file/xz$tod-last6months.tar /path/to/what/I'm/tarring
echo "done"
exit
I want to replace the mtime=20130811
with something similar to the tod=$(date +%F_%H%M%S)
so I don't have to manually change the date and so it will only tar
what has changed over the last 6 months.
Thanks in advance.
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow