TinyApps.Org
Small is beautiful


 HOME

  0. Internet
  1. Text
  2. Graphics
  3. System
  4. File
  5. Misc
  6. Palm
  7. OS X

 BLOG

 DOCS

 FAQ

 RSS (?)





Compress, encrypt, and copy data to offsite server #
Under Windows, I was using AxCrypt and WinSCP from the context menu to compress, encrypt, and send data to an offsite server. Under OS X, I am now using a simple bash command list to achieve the same thing faster and with greater compression:

$ /Applications/file/BetterZip.app/Contents/Resources/7z a -mx9 -pSECRET -mhe ~/Desktop/file.7z ~/Documents/file.ext && scp -P 2012 ~/Desktop/file.7z user@example.com:/home/ && rm ~/Desktop/file.7z

Let's break down what's happening here:
  1. /Applications/file/BetterZip.app/Contents/Resources/7z Call the 7-Zip file archiver contained in BetterZip (which I happened to have from a MacUpdate Promo Bundle). There are several other Mac binaries available or you can download and compile from source.
  2. a Add file(s) to archive
  3. -mx9 Maximum ("Ultra") compression
  4. -pSECRET Set password to SECRET
  5. -mhe Encrypt archive headers (i.e., filenames will be encrypted also)
  6. ~/Desktop/file.7z Name of archive to create or add files to
  7. ~/Documents/file.ext File to compress and encrypt
  1. && Execute next command only if previous command returns an exit status of zero (i.e., wait for command to complete successfully before proceeding)
The next section assumes public-key authentication has been configured (see part 2 of Hardening SSH and Mounting Remote Filesystem in OS X Finder via SSHFS for more information):
  1. scp Secure copy command
  2. -P 2012 Connect via port 2012
  3. ~/Desktop/file.7z Local file to copy
  4. user@example.com:/home/ Remote username and domain followed by directory where file will be copied to
These next two steps are optional:
  1. && Execute next command only if previous command returns an exit status of zero (i.e., wait for command to complete successfully before proceeding)
  1. rm ~/Desktop/file.7z Delete 7z archive from local computer
Notes:
  • As the command list is rather long, you may want to make a permanent alias in OS X by adding a line like this one to your ~/.bash_profile:
    alias bkup='/Applications/file/BetterZip.app/Contents/Resources/7z a -mx9 -pSECRET -mhe ~/Desktop/file.7z ~/Documents/file.ext && scp -P 2012 ~/Desktop/file.7z user@example.com:/home/ && rm ~/Desktop/file.7z'
  • After adding the above line, you can load your .bash_profile without logging out: $ source ~/.bash_profile
    and list current aliases with: $ alias -p
  • Archive all text files in current directory: $ 7z a file.7z *.txt
  • Extract all files from file.7z: $ 7z x file.7z

/mac | Sep 19, 2009



Categories
/blosxom
/eink
/mac
/misc
/nix
/palm
/windows

Blosxom Archive
2012: 5 4 3 2 1
2011: 12 11 10 9 8 7 6 5 4 3 2 1
2010: 12 11 10 9 8 7 6 5 4 3 2 1
2009: 12 11 10 9 8 7 6 5 4 3 2 1
2008: 12 11 10 9 8 7 6 5 4 3 2 1
2007: 12 11 10 9 8 7 6 5 4 3 2 1
2006: 12 11 10 9 8 7 6 5 4 3 2 1
2005: 12 11 10

Blogger Archive
2005: 10 9 8 7 6 5 4 3 2 1
2004: 12 11 10 9 8 7 6 5 4 3 2 1
2003: 12 11 10 9 8 7 6

Ezine Archive
2004: 4 3 2 1
2003: 12 9 8 7 6 5 4 2 1
2002: 12 10 9 8 7 6 5 3 2 1
2001: 12 11 10