GithubHelp home page GithubHelp logo

vectorist / encremotebackup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from perryflynn/encremotebackup

0.0 1.0 0.0 192 KB

Backup files, tar, encrypt with GPG and upload to backup space

License: GNU General Public License v3.0

Perl 100.00%

encremotebackup's Introduction

encremotebackup.pl download the specifed folder with SFTP, creates a tar archive, encrypt the tar with gpg and upload the encrypted tar to another SFTP account.

encremotesqlbackup.pl creates dumps of mysql databases, creates a tar archive, encrypt the tar with gpg and upload the encrypted tar to a SFTP account.

Dependencies

  • tar
  • gnupg
  • mysqldump
  • Perl Module Net::SFTP::Foreign
  • Perl Module XML::Simple
apt-get install libnet-sftp-foreign-perl libxml-simple-perl gnupg tar mysql-client

Installation

  • Generate a gpg key with gpg --gen-key on your local machine. Dont do this on the server!
  • Find out the ID of GPG key gpg --list-keys pub 4096R/997AA45D 2013-09-06 => 997AA45D
  • Export the key. Example: gpg -a --output gpg-key.asc --export 997AA45D
  • Put the public key file to your server
  • Import the public key to gpg: gpg --import gpg-key.asc
  • Put the public key ID in the XML configuration
  • Add a cronjob
# m h  dom mon dow   command
00 02 * * * /home/encremotebackup/encremotebackup.pl -f my-backup.xml
00 03 * * * /home/encremotebackup/encremotesqlbackup.pl -f sql-my-backup.xml

Configuration in XML

The configuration of a backup is specifed in xml.

<?xml version="1.0" encoding="UTF-8"?>
<connection>
   <!-- Specify a name that used for the filename -->
   <name>the-name-of-backup</name>
   <!-- The ID of the imported public gpg key -->
   <publickey>997AA45D</publickey>
   <!-- Store one Month, then delete the backup -->
   <maxageinhours>720</maxageinhours>
   <!-- Source SFTP connection -->
   <source>
      <hostname>localhost</hostname>
      <port>22</port>
      <username>myuser</username>
      <!-- Use keyfile OR password -->
      <!--password>...</password-->
      <keyfile>ssh-myuser.key</keyfile>
      <directory>/home/myuser/</directory>
   </source>
   <!-- Target SFTP connection -->
   <destination>
      <hostname>mycoolonlinespace.example.com</hostname>
      <port>22</port>
      <username>anycustomernumber</username>
      <!-- Use keyfile OR password -->
      <password>akjfhkaakfjhakhfg</password>
      <!--keyfile>...</keyfile-->
      <directory>/mycustomernumber/the-name-of-backup/</directory>
   </destination>
</connection>
<?xml version="1.0" encoding="UTF-8"?>
<connection>
   <!-- Specify a name that used for the filename -->
   <name>sql-mydatabaseserver</name>
   <!-- The ID of the imported public gpg key -->
   <publickey>997AA45D</publickey>
   
   <!-- 3 Months -->
   <maxageinhours>2160</maxageinhours>

   <!-- SFTP Destination -->
   <destination>
      <hostname>my.cool-backupspace.com</hostname>
      <port>22</port>
      <username>my-user-account</username>
      <!-- Use keyfile OR password -->
      <password>mypw</password>
      <!--keyfile>...</keyfile-->
      <directory>/my-user-account/sql-mydatabaseserver/</directory>
   </destination>
   
   <!-- Hostname of mysql server -->
   <hostname>any.sqlhost.com</hostname>
   <!-- Port of mysql server, default: 3306 -->
   <port>3306</port>
   
   <!-- A list of databases of the specifed host -->
   <databases>
      
      <!-- A single database with its username and password -->
      <database>
         <displayname>database-01</displayname>
         <database>d0931478</database>
         <username>d0931478</username>
         <password>fooooopw</password>
      </database>
      
      <database>
         <displayname>database-02</displayname>
         <database>d0931477</database>
         <username>d0931477</username>
         <password>fooooopw</password>
      </database>
      
      <database>
         <displayname>database-03</displayname>
         <database>d0931476</database>
         <username>d0931476</username>
         <password>fooooopw</password>
      </database>
      
   </databases>
</connection>

EOF

encremotebackup's People

Contributors

perryflynn avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.