Use These Python Based Tools for Secured Backup and Recovery of Data
Python, the versatile programming environment, has a variety of uses. This article will familiarise the reader with a few Python based tools that can be used for secured backup and recovery of data.
We keep data on portable hard disks, memory cards, USB Flash drives or other such similar media. Ensuring the long term preservation of this data with timely backup is very important. Many times, these memory drives get corrupted because of malicious programs or viruses; so they should be protected by using secure backup and recovery tools.
Popular tools for secured backup and recovery
For secured backup and recovery of data, it is always preferable to use performance-aware software tools and technologies, which can protect the data against any malicious or unauthenticated access. A few free and open source software tools which can be used for secured backup and recovery of data in multiple formats are: AMANDA, Bacula, Barcos, CloneZilla, Fog, Rsync, BURP, Duplicata, BackupPC, Mondo Rescue, GRSync, Areca Backup, etc.
Python as a high performance programming environment
Python is a widely used programming environment for almost every application domain including Big Data analytics, wireless networks, cloud computing, the Internet of Things (IoT), security tools, parallel computing, machine learning, knowledge discovery, deep learning, NoSQL databases and many others. Python is a free and open source programming language which is equipped with in-built features of system programming, a high level programming environment and network compatibility. In addition, the interfacing of Python can be done with any channel, whether it is live streaming on social media or in real-time via satellite. A number of other programming languages have been developed, which have been influenced by Python. These languages include Boo, Cobra, Go, Goovy, Julia, OCaml, Swift, ECMAScript and CoffeeScript. There are other programming environments with the base code and programming paradigm of Python under development.
Python is rich in maintaining the repository of packages for big applications and domains including image processing, text mining, systems administration,
Web scraping, Big Data analysis, database applications, automation tools, networking, video processing, satellite imaging, multimedia and many others.
Python Package Index (PyPi): https://pypi. python.org/pypi
The Python Package Index (PyPi), which is also known as Cheese Shop, is the repository of Python packages for different software modules and plugins developed as add-ons to Python. Till September 2017, there were more
than 117,000 packages for different functionalities and applications in PyPi. This escalated to 123,086 packages by November 30, 2017.
The table in Figure 1 gives the statistics fetched from ModuleCounts.com, which maintains data about modules, plugins and software tools. Figure 1: Statistics of modules and packages in PyPi in the last week of November (Source: http://www.modulecounts.com/) As Python has assorted tools and packages for diversified applications, security and backup tools with tremendous functionalities are also integrated in PyPi. Descriptions of Python based key tools that offer security and integrity during backup follow.
Rotate-Backups
Rotate-Backups is a simplified command line tool that is used for backup rotation. It has multiple features including flexible rotations on particular timestamps and schedules.
The installation process is quite simple. Give the following command:
$ pip install rotate-backups
The usage is as follows (the table at the bottom of this page lists the options):
$ rotate-backups [Options]
The rotation approach in Rotate-Backups can be customised as strict rotation (enforcement of the time window) or relaxed rotation (no enforcement of time windows).
After installation, there are two files ~/.rotate-backups. ini and /etc/rotate-backups.ini which are used by default.
This default setting can be changed using the command line option config.
The timeline and schedules of the backup can be specified on the configuration file as follows:
# /etc/rotate-backups.ini: [/backups/mylaptop] hourly = 24 daily = 7 weekly = 4 monthly = 12 yearly = always ionice = idle [/backups/myserver] daily = 7 * 2 weekly = 4 * 2 monthly = 12 * 4 yearly = always ionice = idle [/backups/myregion] daily = 7 weekly = 4 monthly = 2 ionice = idle [/backups/myxbmc] daily = 7 weekly = 4 monthly = 2
ionice = idle
Bakthat
Bakthat is a command line tool with the functionalities of cloud based backups. It has excellent features to compress, encrypt and upload the files with a higher degree of integrity and security. Bakthat has many features of data backup with security, including compression with tarfiles, encryption using BeeFish, uploading of data to S3 and Gracier, local backups to the SQLite database, sync based backups and many others.
Installation is as follows:
$ pip install bakthat For source based installation, give the following commands:
$ git clone https://github.com/tsileo/bakthat.git $ cd bakthat
$ sudo python setup.py install
For configuration with the options of security and cloud setup, give the command:
$ bakthat configure Usage is as follows: $ bakthat backup mydirectory To set up a password, give the following command:
$ BAKTHAT_PASSWORD=mysecuritypassword bakthat mybackup mydocument
You can restore the backup as follows: $ bakthat restore mybackup $ bakthat restore mybackup.tgz.enc For backing up a single file, type: $ bakthat backup /home/mylocation/myfile.txt To back up to Glacier on the cloud, type: $ bakthat backup myfile -d glacier
To disable the password prompt, give the following command:
$ bakthat mybackup mymyfile --prompt no
BorgBackup
BorgBackup (or just Borg, for short) refers to a deduplicating backup tool developed in Python, which can be used in software frameworks or independently. It provides an effective way for secured backup and recovery of data.
The key features of BorgBackup include the following: Space efficiency
Higher speed and minimum delays
Data encryption using 256-bit AES
Dynamic compression
Off-site backups
Backups can be mounted as a file system
Compatible with multiple platforms
The commands that need to be given in different distributions to install BorgBackup are given below.
To initialise a new backup repository, use the following command:
$ borg init -e repokey /PathRepository To create a backup archive, use the command given below: $ borg create /PathRepository::Saturday1 ~/MyDocuments
For another backup with deduplication, use the following code:
$ borg create -v --stats /path/to/repo::Saturday2 ~/Documents --------------------------------------------------------Archive name: MyArchive