~debajit/scripts

0d79d3c7782087840cfb1e5ba231eedab00fedd6 — Debajit Adhikary 27 days ago d9da306
Add backup-cmus script to back up local cmus directory
4 files changed, 49 insertions(+), 1 deletions(-)

M README.md
A backup-cmus
A backup.sh
A dir.sh
M README.md => README.md +2 -1
@@ 8,8 8,9 @@ Utility shell scripts to solve various day-to-day problems.
|:----------------|:-------------------------------------------------------------------------------------------------------------------------|
| convert-to-m4a  | Converts the given file to M4A (AAC) format using the Fraunhofer libfdk-aac library (via fdkaac)                         |
| backup-artist   | Back up the given music artist directory to multiple cloud stores.                                                       |
| backup-playlist | Converts a cmus playlist to m3u and backs it up to the cloud, so that other music players like CloudTunes can stream it. |
| sync-artist     | Syncs the artist directory from the local disk to the remote, deleting files from the remote if required.                |
| backup-playlist | Converts a cmus playlist to m3u and backs it up to the cloud, so that other music players like CloudTunes can stream it. |
| backup-cmus     | Back up the local cmus directory (playlists and library in text file format) to the cloud stores configured.             |

## Video


A backup-cmus => backup-cmus +23 -0
@@ 0,0 1,23 @@
#!/usr/bin/env bash

#
# backup-cmus - Back up the local cmus directory to the cloud
#
# SYNOPSIS
#   backup-cmus
#
# DESCRIPTION
#   Copies the files in the local cmus directory (~/.config/cmus) with
#   its playlists and library (which are just text files) to multiple
#   cloud stores. An incremental copy is done, so only changed files
#   are updated.
#

source "backup.sh"
source "dir.sh"
source "notification.sh"

for remote in tulip box
do
  backup_dir "${HOME}/.config/cmus" "${remote}" "Debajit/Backups/cmus"
done

A backup.sh => backup.sh +18 -0
@@ 0,0 1,18 @@
# Backs up the given directory to the given remote specification.
#
# Usage:
#   backup_dir $dir $remote $remote_dir
#
# Example:
#   backup_dir cmus tulip "Debajit/Backups/cmus"
#
function backup_dir {
  local local_dir="${1}"
  local remote="${2}"
  local remote_dir="${3}"

  assert_dir_exists "${local_dir}"

  echo_notify "Backing up to ${remote}..."
  rclone -P "${local_dir}" "${remote}:${remote_dir}"
}

A dir.sh => dir.sh +6 -0
@@ 0,0 1,6 @@
function assert_dir_exists {
  if [[ ! -d "${1}" ]]; then
    echo_error "Directory '${1}' does not exist"
    exit 1
  fi
}