- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: backup few files from one directory script req...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2010 09:23 PM
тАО04-11-2010 09:23 PM
backup few files from one directory script required.
I would like to backup only few files from one directory to another on the same box based on date when files were created.
Scenario:
I have some logs file which overwrite on daily basis and I want to take backup using tar or zip on same machine before overwrite. But the issue is there are many other logs which are normally not in active condition, and I donтАЩt want to take backup of these logs.
I really appreciated if someone shares with me the Script, to sort the logs by date and take backup of latest logs.
Thanks in advance
Khalid
- Tags:
- tar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2010 09:58 PM
тАО04-11-2010 09:58 PM
Re: backup few files from one directory script required.
If your logs are overwritten on daily basis, you could use a cron job to tar/gzip that log files on another location.
Assuming that your logs are named like this: *.log, and you are using sh as your shell, you can use something like this to sort the logs by date:
set -A SAVEDSET `ls -t *.log`
You can access the items from SAVEDSET (contain the file names) with:
${SAVEDSET[
in a while loop.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2010 10:11 PM
тАО04-11-2010 10:11 PM
Re: backup few files from one directory script required.
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=938732
may help.
BR,
Kapil+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2010 01:07 AM
тАО04-12-2010 01:07 AM
Re: backup few files from one directory script required.
Can you please share with me any example,or script?
Actually i have not good knowledge of scripting.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2010 07:50 AM
тАО04-12-2010 07:50 AM
Re: backup few files from one directory script required.
This info isn't available, unless encoded in the filename. The best you can do is look at the modification date or possibly the contents of each file.
>backup only few file
Is there a particular name/suffix for each? How many files would be in the directory? (If too many, you would have to use find(1) vs ls(1) or use ls(1) and grep.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2010 09:42 AM
тАО04-12-2010 09:42 AM
Re: backup few files from one directory script required.
One option could be to cron a script daily which does something like:
#!/usr/bin/sh
REF=/tmp/refpoint
touch -amt $(date "+%m%d"0000) ${REF}
cd /path || exit
FILES=$(find . -xdev -type f -newer ${REF})
tar -cvf /tmp/MYARCHIVE ${FILES}
exit
This creates a reference file whose mtime is that of the current day at 00:00 hours. You then 'cd' to the directory containing the files you want to collect. The 'find()' looks for files modified since the day's beginning and 'tar's then into a tarball of you choice.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2010 09:48 PM
тАО04-12-2010 09:48 PM
Re: backup few files from one directory script required.
Please pay attention to Dennis about date of creation. You only can access the time when the file was last modified.
ls -t sort the files by time modified (latest first) before sorting alphabetically.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2010 01:09 AM
тАО06-08-2010 01:09 AM
Re: backup few files from one directory script required.
Khalid