The files output by the COPY TO command are not encrypted. Therefore, when transferring files to other systems, you should encrypt files using OpenSSL commands, or use file transfer software that performs encrypted communication for Windows, to encrypt the data being transferred.
Use a safe method to delete obsolete plain text files.
You can use the following methods to safely delete files:
fsutil command
Example
# Export the contents of the table my_table to a CSV file. > psql -c "COPY my_table TO 'C:\WINDOWS\Temp\my_table.csv' (FORMAT CSV)" postgres # Encrypt the exported file. > C:\OpenSSL-Win32\bin\openssl enc -e -aes256 -in C:\WINDOWS\Temp\my_table.csv -out my_table.csv.enc (The user is prompted to enter the passphrase to be used for encryption) # Check the size of plain text files, and delete them after zero padding > dir C:\WINDOWS\Temp\my_table.csv > fsutil file setzerodata offset=0 length=7 C:\WINDOWS\Temp\my_table.csv > del C:\WINDOWS\Temp\my_table.csv # Decrypt the encrypted files on other systems. > C:\OpenSSL-Win32\bin\openssl enc -d -aes256 -in my_table.csv.enc -out my_table.csv (The user is prompted to enter the passphrase to be used for decryption)
If you use COPY FROM to import data to tables and indexes in an encrypted tablespace, the imported data is automatically encrypted before being stored.