#!/usr/bin/ruby
require 'fileutils'
mybasedir = '/var/lib/cass'
mydatadir = mybasedir + '/data'
mysnapshotlinksdir = mybasedir + '/snapshots'
FileUtils.remove_dir(mysnapshotlinksdir) if File.exists?(mysnapshotlinksdir)
Dir.chdir mydatadir
mysnapshotdirs = Dir.glob("**/*/")
mysnapshotdirs = mysnapshotdirs.grep(/snapshots\/.+/)
#p mysnapshotdirs
mysnapshots = {}
mysnapshotdirs.each do |mydir|
mysnapshot = {}
myparts = mydir.split('/')
mysnapshot['keyspace'] = myparts[0]
mysnapshot['cf'] = myparts[1]
mysnapshot['tag'] = myparts[3]
mysnapshot['linkdir'] = [mysnapshotlinksdir, mysnapshot['tag'], mysnapshot['keyspace']].join('/')
mysnapshot['link'] = [mysnapshotlinksdir, mysnapshot['tag'], mysnapshot['keyspace'], mysnapshot['cf']].join('/')
mysnapshot['target'] = [mydatadir, mydir].join('/')
#p mysnapshot
FileUtils.mkpath mysnapshot['linkdir'] unless File.exists?(mysnapshot['linkdir'])
File.symlink(mysnapshot['target'], mysnapshot['link']) unless File.symlink?(mysnapshot['link'])
end
Showing posts with label rsync. Show all posts
Showing posts with label rsync. Show all posts
Tuesday, 27 January 2015
Cassandra: links to snapshots in one place
Use rsync with '-L' to copy elsewhere.
Wednesday, 19 June 2013
tsunami-udp: faster than rsync
- build
- sudo apt-get install git gcc
- sudo apt-get install automake autoconf
- git clone git://github.com/rriley/tsunami-udp.git
- cd tsunami-udp
- ./recompile.sh
- sudo make install
- run
- you'll need a port open to allow direct connection from client to server
- unfortunately, this doesn't work through NAT firewalls alone
- firewall / port forwarding
- to server, TCP, 46224 by default
- to client, UDP, 46224 by default
- start up server
- tsunamid myfile.gz
- connect with client
- tsunami set rate 5M connect myserver.domain.com get myfile.gz
- it will flood your connection if you dont set rate properly
- documentation
- http://tsunami-udp.cvs.sourceforge.net/viewvc/tsunami-udp/docs/USAGE.txt
- splits files automatically
- allows wildcards when running server and client commands, "*", namely
- client will auto-find all files served, one after the next
- use forward-slash, i.e. get \*, for client command
- so bash doesn't intrepret the asterisk
- undocumented
- doesn't do subdirectories, better tar that up and have plenty of disk space
Tuesday, 12 March 2013
Specify ssh key when using rsync
WARNING: don't use ~ and don't use double quotes.
- rsync -av -e 'ssh -i /home/me/.ssh/id_rsa_other' root@logging.gumby.com:/remotedir/ /localdir/
Also, some alternative port:
- rsync -av -e 'ssh -p 2221' root@logging.gumby.com:/remotedir/ /localdir/
Labels:
alternative,
exact,
key,
options,
other,
particular,
port,
rsync,
specific,
ssh
Thursday, 14 February 2013
rsync: include only these
- rsync -avP --include=*/ [set of includes] --exclude=*
- for example
- rsync -n -avP --include=*/ --include=*.dat --include=*.idx --exclude=* /informatica/ /backup/informatica/
Tuesday, 8 January 2013
Quick start howto for divish on Debian
- Prep
- Here, there is one backup server and two client servers that need to be backed up
- Make sure root user on backup server can ssh to mybox01.mydomain.net and mybox02.mydomain.net without password
- Later, much later, see online for better, more secure ways
- install dirvish and rsync on server, rsync on clients
- apt-get install dirvish
- apt-get install rsync
- Clients
- The below are just example directories, use your own, the ones you want backed up
- mkdir -p /data/backups/
- mkdir -p /data/backups/etc
- mkdir -p /data/backups/var/log
- rsync -av /etc/ /data/backups/etc/
- rsync -av /opt/ /data/backups/opt/
- Make a cron job to do the rsyncs above nightly
- Server
- mkdir -p /backup/dirvish/mybox01/dirvish
- mkdir -p /backup/dirvish/mybox02/dirvish
- vi /backup/dirvish/mybox01/dirvish/default.conf
- get contents below
- vi /backup/dirvish/mybox02/dirvish/default.conf
- get contents below
- dirvish --vault mybox01 --init
- dirvish --vault mybox02 --init
- Verify
- Backed up files should now be under /backups/dirvish on backup server
- tree /backup/ -d -L 3
- find /backup/dirvish -ls | less
- Tell dirvish to do nightly pull
- vi /etc/dirvish/master.conf.mybackup
- get contents below
- Tomorrow, verify the pull worked, and next week too
- Exclusion and expire options
- Research options one can add to master.conf.mybackup
/etc/dirvish/master.conf
/backup/dirvish
Exclude:
lost+found/
/etc/dirvish/master.conf.mybackup
Runall:
mybox01
mybox02mybox01
/backup/dirvish/mybox01/dirvish/default.conf
client: mybox01.mydomain.net
tree: /data/backups
xdev: true
index: gzip
/backup/dirvish/mybox02/dirvish/default.conf
client: mybox02.mydomain.net
tree: /data/backups
xdev: true
index: gzip
Subscribe to:
Posts (Atom)
Interview questions: 2020-12
Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer Networking Layer 1 vs Layer 4 haproxy u...
-
CRITICAL: AWS now offers internal VPC DNS! Below is no longer necessary AFAIK. Woo hoo! http://aws.amazon.com/about-aws/whats-new/2014/...
-
build sudo apt-get install git gcc sudo apt-get install automake autoconf git clone git://github.com/rriley/tsunami-udp.git cd tsunam...
-
From: https://bugs.eclipse.org/bugs/show_bug.cgi?id=382972#c4 Assumptions: jEdit was installed into /Applications directory. Close any...