Giter Site home page Giter Site logo

ffsync's Introduction

ffsync

bash script for fetching and pushing a list of files to and from a ssh host

Motivation

This is a bash script to fetch a list of files from a defined ssh host and save them to a subdirectory while preserving the filesystem structure. It can then also push all files found in a subdirectory to a ssh host.

It originated as two seperate scripts for backing up configuration files of Freifunk routers.

Behind the scenes, it compresses files to stdout with tar, pipes that through a ssh connection and then extracts from stdin again. It is important to note that when pushing files, they all get assigned --owner=0 --group=0. This is due to the fact that the script is intended for network devices with a single superuser. It avoids the need for superuser rights locally when editing files and 'preserves' file ownerships properly on remote devices.

The configuration might resemble ansible a bit and you could probably do all this with ansible too. But this script is much simpler and more lightweight as it serves a very specific purpose. It does not require anything besides a ssh server and the tar command remotely.

Usage

$ ffsync <mode> [-c config] [-h host] [-d directory] [-l filelist] [-y]

<mode> can be one of:

  • push copy all files in a local directory to the remote host
  • pull copy the files specified in a file from the remote host and save to a local directory

By default the variables are read from ffsync.yml, which is file in YAML format. This can be overriden with the following options. All variables are shown before copying and the user is asked for confirmation.

Variables can be overriden with the following options:

  • [-c config.yml] read configuration from config.yml instead
  • [-h host] connect to host instead (this can be hostname + options specific to your ssh client)
  • [-d dir] use dir as local directory instead
  • [-l "file /path/to/dir/"] fetch the file and directory /path/to/dir (including subfolders) instead
  • [-y] override the confirmation dialog

Options can be specified in any order and combinations like ffsync pull -yh host are also possible.

Configuration

The configuration is done in a YAML-formatted file:

hostconf:   freifunk-node
datadir:    filesystem
yesyes:     false
filelist:
    - /etc/profile
    - /etc/hosts
    - /etc/sysupgrade.conf
    - /etc/dropbear/authorized_keys
    - /etc/config/network
    - /etc/config/wireless
    - /root/

There are plans to allow more than one host with different directories per file.

ffsync's People

Contributors

ansemjo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.