Synco Documentation

  1. Introduction
  2. Installation
  3. Concepts
  4. Backup Policy
  5. Storage Solutions
  6. Backup Scripts
  7. Basic Server Backup
  8. Backup Staging
  9. DNS Indirection
  10. Server Synchronization

A backup script represents a single backup process that involves one or more computers and directories. By default, Synco relies on RSync, but there are a variety of different tools available for copying data.

Basic Data Synchronisation

This script will copy data from server1a.example.com to server1b.example.com. Because the method is configured as a data :push, you will need to run this script on the master server (e.g. :src) for it to have any effect.

#!/usr/bin/env ruby

require 'rubygems'

require 'lsync'
require 'lsync/shells/ssh'
require 'lsync/methods/rsync'

Synco::run_script do |script|
    script.method = Synco::Methods::RSync.new(:push, :arguments => ["--archive", "--delete"])
	
	script.master = :src
	
	server(:src) do |server|
	    server.host = "server1a.example.com"
		server.root = "/"
	end
	
	server(:dst) do |server|
	    server.host = "server1b.example.com"
		server.root = "/"
	end
	
	backup('etc', 'var', 'srv', 'home')
end

Because this script is modifying system directories, you may need to run it as root. Because backup often involves sensitive files, it is important to consider security when designing a backup policy.

Basic Incremental Backup

This script will copy data from the running server to a sub-directory /backups. The data is first copied using RSync to /backups/latest/$directory where $directory is one of 'etc', 'var', 'srv', 'home'. Once the data has been copied successfully, the :success event is fired: lsync-rotate moves the latest backup to a directory based on the current date and time. Then, lsync-prune prunes old backups according to the specified policy.

#!/usr/bin/env ruby

require 'rubygems'

require 'lsync'
require 'lsync/shells/ssh'
require 'lsync/methods/rsync'

Synco::run_script do |script|
	script.method = Synco::Methods::RSyncSnapshot.new(:push, :arguments => ["--archive", "--compress", "--stats"])
	
	script.master = :src
	
	server(:src) do |server|
		server.root = "/"
	end
	
	server(:dst) do |server|
		server.root = "/backups"
		
		server.on(:success) do |controller|
			controller.run ['lsync-rotate', script.method.inprogress_path]
			controller.run ['lsync-prune', '--default-policy']
		end
	end
	
	backup('etc', 'var', 'srv', 'home')
end