diff --git a/utils/sync-config b/utils/sync-config new file mode 100644 index 0000000..05d965d --- /dev/null +++ b/utils/sync-config @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# paths +dropbox_src_root='remote:notes' +dropbox_src_memos=${dropbox_src_root}/memo/public +dropbox_src_assets=${dropbox_src_root}/_Assets/public + +mirror_dest_root=/home/kazbo/notes_public_items_mirror +mirror_dest_memos=${mirror_dest_root}/memo/ +mirror_dest_assets=${mirror_dest_root}/assets/ + +git_repo_root=/home/kazbo/public_notes +git_repo_dest=${git_repo_root}/content + +# commands +RCLONE='rclone --copy-links' +RSYNC='rsync -a --copy-links --delete' +GIT=git + + diff --git a/utils/sync-notes.sh b/utils/sync-notes.sh new file mode 100755 index 0000000..3ab4c8e --- /dev/null +++ b/utils/sync-notes.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +. ./sync-config +echo "syncing notes..." + +## sync dropbox -> mirror +# memos +$RCLONE sync ${dropbox_src_memos} ${mirror_dest_memos} -v + +# assets +$RCLONE sync ${dropbox_src_assets} ${mirror_dest_assets} -v + + +## sync mirror -> git repo dest +# memos +$RSYNC ${mirror_dest_memos} ${git_repo_dest} +$RSYNC ${mirror_dest_assets} ${git_repo_dest}/assets/ + +pushd ${git_repo_root} + +## git +if [[ `git status --porcelain` ]]; then + # Changes + echo 'changes!' + git add . + git commit -m "sync notes(auto)" + git pull + git push +else + # No changes + : +fi + +popd +