Saturday, September 26, 2015

Pyzano for Data Backup


Pyzano (https://github.com/dreilly369/PyzanoFSIC) is a tool I use for a lot for file system tasks. From monitoring for unauthorized changes, to creating malware signatures for Host-based Intrusion Detection Systems (HIDS). Today though, I want to write about Pyzano's ability to be used as a lightweight data backup and file sharing system.

Setup

You will need a couple of things setup for this to work. I am using a private cloud type setup:
  • MySQL server (initialized with Pyzano) in my personal cloud. In my example the Mysql Server is on a 1TB Network Attached Storage (NAS) at 192.168.0.4
  • Client A: at 192.168.0.3
    • Change configuration file to use MYSQLDURL : 192.168.0.4
    • Change configuration file to use HOSTNAME: DanToo-Laptop
  • Client B: at 192.168.0.2
    • Same configuration setup as Client A 
  • Copy of Pyzano from GitHub.

Use case

I don't know about you, but I love my music collection. When I download a new song, I want to back it up to my NAS so I don't lose it if my laptop dies. The files I want to duplicate are saved at: /media/ExternalData/music/.
List of files to save

In addition to copying them, I also want to transfer them to my PwnTab. 

To start, I will create a backup of all the files in the target directory on Client A like so:

python pyzano.py --directory /media/ExternalData/music/ --store-file True --no-scan True --handle-added add --handle-deleted delete --handle-changed update

That will run Pyzano in No-Scan mode with the --store-file option set to True and the source directory set to the proper location.
Successful save

Supposing I lose the folder or any contents on DanToo-Laptop (oh no! I ran rm /media/ExternalData/music/DEF\ CON\ 22\ Live\ Music\ -\ DJ*.mp3), I can restore them simply by running Pyzano with the --handle-deleted option set to restore (shorthand:  -w r)

python pyzano.py  --directory /media/ExternalData/music/ --handle-deleted restore --handle-changed restore --no-scan True

Restored the lost files
This can also be shared between two or more hosts simply by creating the appropriate directory, changing the host names to match, and running the restore command from above. In my example Client B copies the configuration of Client A. You need to create the desired directory with:
mkdir -p /media/ExternalData/music

Then run the restore command on Client B. All the files will be seen to be missing and restored from their binary backups.

Successfully transferred to Client B
Pyzano may take a while depending on the speed of your network, the size of your files, and the number of files that need to be restored.

It may be best to limit this to important files and files related to malware analysis tasks. Also of note: This shared file method is not currently cross platform since the paths must match exactly.

No comments:

Post a Comment