Giter Club home page Giter Club logo

purrsync's Introduction

Purrsync - A wrapper for rsync

About

Purrsync is an rsync wrapper for syncing files based on package collections.

Some Examples

Simple invocation

The simplest invocation is: Synchronizing from a MAINFILE (file list) everything from SRC to DEST.

purrsync -m $MAINFILE $SRC $DEST

Here is a realistic example of the above.

mkdir -v /tmp/etc
cd /etc
find . > /tmp/mainfile
purrsync -m /tmp/mainfile /etc /tmp/etc

Ignore list

An ignore file list can be used.

cd /etc
find . > /tmp/mainfile
find -iname \*.key > /tmp/ignorefile
purrsync -m /tmp/mainfile -i /tmp/ignorefile /etc /tmp/etc

Piping commands

Instead of creating files, purrsync can run the commands for you.

cd /etc
purrsync --main-exec "find" --ignore-exec "find -iname \*.key" /etc /tmp/etc

Package sorting

The main goal of this script was to sort backup configurations for packages on a per-package basis. On Gentoo this can be achieved with the following.

purrsync -p -o -x "find /etc" -e "qlist {}" -L "qfile /etc | awk '{ print \$1 }'" / /tmp/etc
  • The -p flag is required for package sorting.
  • The -o flag is for creating a special directory for orphaned files (without packages).
  • The -x flag is synonymous with --main-exec.
  • The -e flag runs "qlist {}" for every package, where {} is replaced with the package name.
  • The -L flag runs "qfile /etc | awk '{print \$1 }'" on /bin/sh to get a list of the relevant packages. These names are fed into qlist {}.

Only the set intersection between -x and -e are synchronized into the package destinations.

Arguments for rsync

Arguments can be passed to rsync.

purrsync -m FILELIST --rsync-args="-v" / /tmp/root

The path to the rsync binary can be specified,

purrsync -m FILELIST --rsync-bin="/usr/bin/rsync" / /tmp/root

by default purrsync uses the which command to find the location of rsync.

Backup directory

A backup directory can be given to purrsync relative to the main, pkg and orphan directories in the destination.

purrsync --backup-dir="backup-dir" -m FILELIST / /tmp/root

This can be used to create incremental backup snapshots.

purrsync --rsync-args="-u" -b "$(date +%F-%I%M%p-%Z)" -m FILELIST / /tmp/root

The rsync -u option specifies to only update the destination if files are newer on the source.

Destination Directory Structure

The destination directory is structured as follows.

  • destination
    • main
      • root
      • backup-dir
    • orphan
      • root
      • backup-dir
    • pkg
      • package_name
        • root
        • backup-dir

The destination passed to rsync always ends in root.

Conclusions

I hope this has been a helpful guide.

If you have any suggestions, comments or would like to submit a PR, please be in touch.

Have a nice day! :)

purrsync's People

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.