add sync script
This commit is contained in:
parent
ce9fc35272
commit
887089dd36
2 changed files with 53 additions and 0 deletions
19
utils/sync-config
Normal file
19
utils/sync-config
Normal file
|
@ -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
|
||||
|
||||
|
34
utils/sync-notes.sh
Executable file
34
utils/sync-notes.sh
Executable file
|
@ -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
|
||||
|
Loading…
Reference in a new issue