- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: copy with data retention for 5 days then overw...
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
тАО05-19-2009 08:00 AM
тАО05-19-2009 08:00 AM
#!/usr/bin/ksh
timestamp=`date | awk {'print $2 $3 $6'}`
for dir in /mytest/test1
do
cp -rp ${dir} /DATA/BACKUP/${dir}.${timestamp}
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2009 08:24 AM
тАО05-19-2009 08:24 AM
Re: copy with data retention for 5 days then overwrite
doubtful...the "destination" directory in the script posted includes a "timestamp" in the form of "
A) Surely you don't want to place "new" data in the old directory, which is what "overwrite" implies.
B) Do you want to continue to generate new directories with current "timestamp" and remove the old one?
C) Are you sure you only want to keep data 5 days, and not 7 (i.e. on Monday delete the prior Monday????)
D) Or would simply creating a /DATA/BACKUP/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2009 08:43 AM
тАО05-19-2009 08:43 AM
Re: copy with data retention for 5 days then overwrite
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2009 09:10 AM
тАО05-19-2009 09:10 AM
Solution#!/usr/bin/ksh
timestamp=`date +%a`
for dir in /mytest/test1
do
rm -rf /DATA/BACKUP/${dir}.${timestamp}
cp -rp ${dir} /DATA/BACKUP/${dir}.${timestamp}
done
timestamp will now have a value of mon, tue, wed, thu, fri (sat or sun would be there if run on weekends
it will attempt to remove an existing /DATA/BACKUP/${dir}.${timestamp} and then recreate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2009 09:16 AM
тАО05-19-2009 09:16 AM
Re: copy with data retention for 5 days then overwrite
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-19-2009 09:25 AM
тАО05-19-2009 09:25 AM
Re: copy with data retention for 5 days then overwrite
%a gives the weekday names. If you want numbers that sort, you can use %u (1-7) or %w (0-6)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2009 08:16 AM
тАО05-20-2009 08:16 AM
Re: copy with data retention for 5 days then overwrite
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2009 10:30 PM
тАО05-20-2009 10:30 PM
Re: copy with data retention for 5 days then overwrite
You can just do "mkdir -p" for the directory path then use cp.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 08:35 AM
тАО05-28-2009 08:35 AM