Advertisement
QuangDepTrai

Move Mail Message to Another Database by Create Date

Aug 20th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.77 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ## GET time to query data
  4. move_time=`date --date="18 months ago" "+%Y-%m-%d %T"`
  5. echo ${move_time}
  6.  
  7. ## COPY data mail_message
  8. echo "Copy data mail_message"
  9. psql wms_local -c \
  10. "\copy (SELECT id,subject,date,body,parent_id,model,res_id,record_name,message_type,subtype_id,mail_activity_type_id,email_from,author_id,no_auto_thread,message_id,reply_to,mail_server_id,create_uid,create_date,write_uid,write_date$
  11. psql archived_wms -c "\copy mail_message(id,subject,date,body,parent_id,model,res_id,record_name,message_type,subtype_id,mail_activity_type_id,email_from,author_id,no_auto_thread,message_id,reply_to,mail_server_id,create_uid,create$
  12.  
  13. echo "\nRemoving data mail_message"
  14. psql wms_local -c "DELETE FROM mail_message WHERE create_date <= '${move_time}'"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement