1
Fork 0
mirror of https://github.com/Steffo99/backup-duplicity.git synced 2024-10-16 06:07:25 +00:00

Split backup and restore

This commit is contained in:
Steffo 2023-05-17 14:36:47 +02:00
parent f3809f4b0f
commit d3c8292184
Signed by: steffo
GPG key ID: 2A24051445686895
4 changed files with 76 additions and 50 deletions

View file

@ -43,30 +43,30 @@
<option name="showLibraryContents" value="true" />
<option name="showVisibilityIcons" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "/store/Documents/Workspaces/Steffo99/docker-backup-duplicity",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2",
"settings.editor.selected.configurable": "editor.preferences.folding",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/store/Documents/Workspaces/Steffo99/docker-backup-duplicity&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;editor.preferences.folding&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"GitStage.ChangesTree.GroupingKeys": [
"directory",
"module",
"repository"
&quot;keyToStringList&quot;: {
&quot;GitStage.ChangesTree.GroupingKeys&quot;: [
&quot;directory&quot;,
&quot;module&quot;,
&quot;repository&quot;
]
}
}]]></component>
}</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
@ -79,7 +79,7 @@
<workItem from="1684100629419" duration="1075000" />
<workItem from="1684324347198" duration="751000" />
<workItem from="1684325989651" duration="719000" />
<workItem from="1684326731845" duration="82000" />
<workItem from="1684326731845" duration="241000" />
</task>
<task id="LOCAL-00001" summary="Add proper python cryptography requirements">
<created>1684080793392</created>
@ -109,7 +109,21 @@
<option name="project" value="LOCAL" />
<updated>1684326475873</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="Quote variables">
<created>1684326824058</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1684326824058</updated>
</task>
<task id="LOCAL-00006" summary="Fix idea modules">
<created>1684326830505</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1684326830505</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -131,6 +145,8 @@
<MESSAGE value="Rename stage to &quot;final&quot;" />
<MESSAGE value="Set a+x on backup.sh" />
<MESSAGE value="Backup at startup" />
<option name="LAST_COMMIT_MESSAGE" value="Backup at startup" />
<MESSAGE value="Quote variables" />
<MESSAGE value="Fix idea modules" />
<option name="LAST_COMMIT_MESSAGE" value="Fix idea modules" />
</component>
</project>

View file

@ -7,24 +7,9 @@ set -e
# It's duplicity's fault!
export PASSPHRASE=$(cat "${DUPLICITY_PASSPHRASE_FILE}")
case "$MODE" in
backup)
echo "Launched in backup mode, performing backup..." >> /dev/stderr
duplicity \
--allow-source-mismatch \
--full-if-older-than "${DUPLICITY_FULL_IF_OLDER_THAN}" \
/mnt \
"${DUPLICITY_TARGET_URL}"
;;
restore)
echo "Launched in restore mode, restoring backup..." >> /dev/stderr
duplicity \
--force \
--allow-source-mismatch \
"${DUPLICITY_TARGET_URL}" \
/mnt
;;
*)
echo "No such mode." >> /dev/stderr
;;
esac

View file

@ -1,7 +1,17 @@
#!/bin/sh
case "$MODE" in
backup)
echo "Running first backup..."
./backup.sh
echo "Running cron for daily backups..."
crond -f -d 5 -l info
;;
restore)
echo "Restoring from latest backup..."
./restore.sh
;;
*)
echo "No such mode." >> /dev/stderr
;;
esac

15
restore.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
set -e
# Get secrets from files
# Insecure, but there's not much I can do about it
# It's duplicity's fault!
export PASSPHRASE=$(cat "${DUPLICITY_PASSPHRASE_FILE}")
echo "Launched in restore mode, restoring backup..." >> /dev/stderr
duplicity \
--force \
--allow-source-mismatch \
"${DUPLICITY_TARGET_URL}" \
/mnt