e

Backups with Dropbox Using 7zip

This is an alternative method of the Backups with Dropbox script that employs 7zip. 7zip includes built-in encryption and higher compression ratios. 7zip must be installed before using this script with the command

sudo apt-get install p7zip-full

and a directory needs created with this command run from your home directory:

mkdir backup_tmp

The modified script:

#!/bin/sh

# set "filename" as an alias to ''backup-<date>.tar'' 
# "date" will be automatically generated.
filename="backup-$(date +%Y%m%d).tar"

# create the tarball with the name "filename" in user's home backup_tmp directory
# "-C ~" switches to user's home directory
# followed by space separated list of directories to tar
# followed by --exclude for directories to NOT tar. 
# Each must be in quotes and have its own --exclude statement
tar -cf ~/backup_tmp/$filename -C ~ Documents .mozilla --exclude "Cache"

# 7z a: This creates a compressed file in .7z format.
# -mhe=on: enables archive header encryption.
# -psecretkey: sets the password for the .7z file. In this case the password will be "secretkey". 
# For example, a password like 012jui4@1 has to be written as -p012jui4@1.
# ~/backup_tmp/$filename: is the .tar file that's going to be compressed by p7zip.
7z a ~/Dropbox/$filename.7z -mhe=on -psecretkey ~/backup_tmp/$filename

# delete the original tarball.
rm ~/backup_tmp/$filename

# find and remove backup files older than 2 days
find ~/Dropbox/ -type f -mtime +2 -name 'backup-*' -delete

Your backup file will be in your Dropbox folder with the .tar.7z extension.

To restore the backup

You got to copy or move the backup file to your home directory. For example, you have copied the file to your home directory and it's called “backup-20110518.tar.7z”.

In a terminal run:

7z x backup-20110518.tar.7z

You'll be asked for the password to decrypt and decompress the file. Type it and press enter.

You will get the .tar file “backup-20110518.tar”. You can untar it with:

tar xf backup-20110518.tar

Be aware!! This will overwrite all of your current files with the ones you had backed up previously. If you do NOT want this behavior (for example, there are only a few files you wish to restore but keep the current versions of others) move the backup file into another directory (create one if necessary) and run the above command on it there. Then move the file(s) you wish to restore to the proper location(s).


User Feedback

backups_with_dropbox_using_7zip
Did you find this article helpful?
Yes, right on the money!
 
100%(1)
Somewhat. Needs work.
0%(0)
Not really
0%(0)
Not at all.
0%(0)

If you would like to comment or make further suggestions, please leave a note on our Comments page (you will have to Create an Account if you haven't already).


original article by txemijendrix

 
backups_with_dropbox_using_7zip.txt · Last modified: 2011/05/24 07:41 by ottermaton · [Old revisions]


© Copyright Bodhi Linux 2012. All Rights Reserved - Hosted by vaultnetworks