我在增量备份中一直不明白的是,通过口是心非,修改后的本地文件是否会在备份存储中被覆盖,即增量备份是否可以恢复已修改文件的旧版本?
我正在做每日增量备份和每月完整备份,两者都是口是心非
每日备份脚本(中/etc/cron.daily/
)
#!/bin/sh
adddate() {
while IFS= read -r line; do
printf '%s %s\n' "$(date):" "$line";
done
}
# be sure external drives are mounted
mount -a
# backup to HDD backup B, using duplicity
echo "\n\nBacking up /home and /etc into /mnt/backupB with duplicity (incremental backup)" | adddate >> /var/log/daily-backup.log 2>&1
export PASSPHRASE=****
duplicity --exclude='**/.cache/' --include /home --include /etc --exclude '**' / file:///mnt/backupB | adddate >> /var/log/daily-backup.log 2>&1
unset PASSPHRASE
每月备份脚本(中/etc/cron.monthly/
)
#!/bin/sh
adddate() {
while IFS= read -r line; do
printf '%s %s\n' "$(date):" "$line";
done
}
# be sure external drives are mounted
mount -a
# backup to HDD backup B, using duplicity
echo "\n\nBacking up /home and /etc into /mnt/backupB with duplicity (full backup)" | adddate >> /var/log/monthly-backup.log 2>&1
export PASSPHRASE=*****
duplicity full --exclude='**/.cache/' --include /home --include /etc --exclude '**' / file:///mnt/backupB | adddate >> /var/log/monthly-backup.log 2>&1
unset PASSPHRASE
我的问题是:何时何地使用口是心非验证?在增量或完全或两者之后?
我已经在 cron 工作中使用 duplicity 一年了,效果很好。从上周开始,我收到以下消息:
Ausdruckbasierte Dateiliste wird gelesen /home/mu/.config/exclude-b2.txt
Traceback (most recent call last):
File "/usr/bin/duplicity", line 1637, in <module>
if "Forced assertion for testing" in util.uexc(e):
File "/usr/lib64/python2.7/site-packages/duplicity/util.py", line 82, in uexc
return ufn(m)
File "/usr/lib64/python2.7/site-packages/duplicity/util.py", line 63, in ufn
return filename.decode(globals.fsencoding, 'replace')
AttributeError: 'tuple' object has no attribute 'decode'
我的 Fedora 30 系统上对软件包的最后一次升级duplicity
是 2019-05-09,我运行的是 0.7.19 版本。备份转到 Backblaze B2。
有什么办法可以把它固定下来吗?
今天晚上,在某种内核恐慌之后,我不得不硬关闭我的电脑。
当我重新启动时,我注意到我~/.ssh/id_rsa
已被一个空文件替换。
重新启动到 USB 并fsck
在我的主分区上运行报告文件系统状况良好。
仅此一点都不是问题。我访问原始密钥。但是,我担心其他文件可能已被类似截断。
我上次使用 的备份deja-dup
是在三天前,所以我可以完全回滚,但我宁愿只询问deja-dup
从那时起哪些文件发生了变化并寻找“可疑”文件。
这似乎正是 的目的duplicity verify
,所以在浏览了一些手册页之后,我尝试了:
duplicity verify --verbosity 4 --no-encryption file:///path/to/backup/ /home/${USER}
在没有报告更改的情况下运行完成。至少,我预计我~/.ssh/id_rsa
会被检测到,但我已经添加、删除和更改了其他文件。
我的下一次尝试是相同的,但带有--compare-data
标志:
duplicity verify --verbosity 4 --no-encryption file:///path/to/backup/ /home/${USER}
这似乎报告我的主文件夹中的每个文件都是新的,开始如下:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Dec 15 11:43:22 2017
Difference found: File . has permissions 1000:1001 700, expected 0:0 555
Difference found: New file .AndroidStudio2.3
Difference found: New file .AndroidStudio2.3/config
Difference found: New file .AndroidStudio2.3/config/inspection
Difference found: New file .AndroidStudio2.3/config/inspection/Default.xml
我已经安装了几个月的 Android Studio,所以它肯定在我三天前的备份中,并且ls
报告Default.xml
仍然存在并且长度为 108 字节。
作为最后的努力,我将目标目录更改为/
,因为在使用时这似乎是根目录duplicity list-current-files
,这需要添加一些正则表达式来限制重复性以仅考虑我的主文件夹:
duplicity verify --verbosity 4 --compare-data --no-encryption --include-regexp ".*home/${USER}/\.ssh.*" --exclude-regexp ".*" file:///path/to/backup/ /
报告我的主文件夹不存在的有趣效果:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Dec 15 11:43:22 2017
Difference found: File home is missing
Difference found: File home/${USER} is missing
Difference found: File home/${USER}/.AndroidStudio2.3 is missing
Difference found: File home/${USER}/.AndroidStudio2.3/config is missing
Difference found: File home/${USER}/.AndroidStudio2.3/config/inspection is missing
Difference found: File home/${USER}/.AndroidStudio2.3/config/inspection/Default.xml is missing
在这一点上,我当然只是误解了我应该如何使用重复性。如何验证由 生成的备份deja-dup
?
duplicity list-current-files
有输出开始:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Fri Dec 15 11:43:22 2017
Tue Feb 6 19:36:56 2018 .
Wed Aug 2 17:32:09 2017 home
Tue Feb 6 00:38:20 2018 home/${USER}
Sat May 13 18:49:24 2017 home/${USER}/.AndroidStudio2.3
Thu Jun 22 19:42:14 2017 home/${USER}/.AndroidStudio2.3/config
Sat May 13 18:57:45 2017 home/${USER}/.AndroidStudio2.3/config/inspection
Sat May 13 18:57:45 2017 home/${USER}/.AndroidStudio2.3/config/inspection/Default.xml
我想备份具有重复性的配置文件(隐藏,以点开头)。只有文件,没有目录。以下命令
duplicity --include '/home/foo/.*' --exclude '/home/foo/**' /home/foo sftp://myserver/backup --dry-run
备份以点开头的所有内容,因此还包括配置目录。
另一方面
duplicity --exclude '/home/foo/**' --include '/home/foo/.*' /home/foo sftp://myserver/backup --dry-run
生产
命令行 include glob: /home/foo/.* 仅指定包含文件。因为默认是包含所有文件,所以表达式是多余的。退出,因为这可能不是你的意思。
我没有别的想法。如何仅备份以点开头的文件。
我希望使用duplicity
(我经常使用它,通常没有问题)/etc
和/root
. 我希望.cache
从/root
目录中排除。我尝试:
duplicity incremental --full-if-older-than 30W --include /etc \
--include /root --exclude '/root/.cache' --exclude / \
--verbosity info / scp://TARGET
这通常有效,但/root/.cache
包含在备份中。而不是'/root/.cache'
我尝试了不同的表达模式:/root/.cache
, "/root/.cache"
, "**.cache"
, '**.cache'
,''**.cache''
和其他几个,结果相同。
根据duplicity手册(我在 openSUSE 上有 0.7.12),表达式"**.cache"
应该可以正常工作。我是误读了手册还是做错了什么?
无论我在这个重复配置文件上尝试哪个命令,它总是会出错。
duply database status
duply database bkp
duply database purge
它们都返回类似于以下的跟踪
Start duply v1.11.3, time is 2017-11-30 12:20:12.
Using profile '/etc/duply/database'.
Using installed duplicity version 0.7.12, python 2.7.5, gpg 2.0.22 (Home: ~/.gnupg), awk 'GNU Awk 4.0.2', grep 'grep (GNU grep) 2.20', bash '4.2.46(1)-release (x86_64-redhat-linux-gnu)'.
Checking TEMP_DIR '/srv/mysql/logs/duply_backup/duply_tmp' is a folder and writable (OK)
Test - En/Decryption skipped. (GPG disabled)
--- Start running command PURGE at 12:20:12.397 ---
Using archive dir: /srv/mysql/logs/duply_backup/duply_cache/duply_database
Using backup name: duply_database
Import of duplicity.backends.acdclibackend Succeeded
Import of duplicity.backends.azurebackend Succeeded
Import of duplicity.backends.b2backend Succeeded
Import of duplicity.backends.botobackend Succeeded
Import of duplicity.backends.cfbackend Succeeded
Import of duplicity.backends.copycombackend Succeeded
Import of duplicity.backends.dpbxbackend Failed: No module named dropbox
Import of duplicity.backends.gdocsbackend Succeeded
Import of duplicity.backends.giobackend Succeeded
Import of duplicity.backends.hsibackend Succeeded
Import of duplicity.backends.hubicbackend Succeeded
Import of duplicity.backends.imapbackend Succeeded
Import of duplicity.backends.lftpbackend Succeeded
Import of duplicity.backends.localbackend Succeeded
Import of duplicity.backends.mediafirebackend Succeeded
Import of duplicity.backends.megabackend Succeeded
Import of duplicity.backends.multibackend Succeeded
Import of duplicity.backends.ncftpbackend Succeeded
Import of duplicity.backends.onedrivebackend Succeeded
Import of duplicity.backends.par2backend Succeeded
Import of duplicity.backends.pydrivebackend Succeeded
Import of duplicity.backends.rsyncbackend Succeeded
Import of duplicity.backends.ssh_paramiko_backend Succeeded
Import of duplicity.backends.ssh_pexpect_backend Succeeded
Import of duplicity.backends.swiftbackend Succeeded
Import of duplicity.backends.sxbackend Succeeded
Import of duplicity.backends.tahoebackend Succeeded
Import of duplicity.backends.webdavbackend Succeeded
Main action: remove-old
================================================================================
duplicity 0.7.12 (March 21, 2017)
Args: /bin/duplicity remove-older-than 8W --archive-dir /srv/mysql/logs/duply_backup/duply_cache --name duply_database --no-encryption --verbosity 5 --full-if-older-than 4W --volsize 50 --include-filelist /etc/duply/database/include --exclude-filelist /etc/duply/database/exclude --rsync-options --rsh="ssh -oBatchMode=yes -i /root/.ssh/duplicity_scp.dsa" --copy-links rsync://[email protected]:22//backup-lun/duplicity//eventlogdb-core-01/database
Linux eventlogdb-core-01.ecnza.net 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64
/bin/python2 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
================================================================================
Reading results of 'rsync -e 'ssh -p 22 -oBatchMode=yes ' --rsh="ssh -oBatchMode=yes -i /root/.ssh/duplicity_scp.dsa" [email protected]:/backup-lun/duplicity//eventlogdb-core-01/database/'
Local and Remote metadata are synchronized, no sync needed.
Reading results of 'rsync -e 'ssh -p 22 -oBatchMode=yes ' --rsh="ssh -oBatchMode=yes -i /root/.ssh/duplicity_scp.dsa" [email protected]:/backup-lun/duplicity//eventlogdb-core-01/database/'
Processing local manifest /srv/mysql/logs/duply_backup/duply_cache/duply_database/duplicity-full.20171010T231503Z.manifest.part (634880)
Using temporary directory /srv/mysql/logs/duply_backup/duply_tmp/duplicity-k1XfbU-tempdir
Traceback (most recent call last):
File "/bin/duplicity", line 1546, in <module>
with_tempdir(main)
File "/bin/duplicity", line 1540, in with_tempdir
fn()
File "/bin/duplicity", line 1391, in main
do_backup(action)
File "/bin/duplicity", line 1416, in do_backup
globals.archive_dir).set_values()
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 710, in set_values
self.get_backup_chains(partials + backend_filename_list)
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 836, in get_backup_chains
add_to_sets(f)
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 830, in add_to_sets
if new_set.add_filename(filename):
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 101, in add_filename
self.set_manifest(filename)
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 148, in set_manifest
self.set_files_changed()
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 128, in set_files_changed
mf = self.get_manifest()
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 250, in get_manifest
return self.get_local_manifest()
File "/usr/lib64/python2.7/site-packages/duplicity/collections.py", line 224, in get_local_manifest
return manifest.Manifest().from_string(manifest_buffer)
File "/usr/lib64/python2.7/site-packages/duplicity/manifest.py", line 208, in from_string
assert filecount == len(self.files_changed)
AssertionError
12:20:14.362 Task 'PURGE' failed with exit code '30'.
--- Finished state FAILED 'code 30' at 12:20:14.362 - Runtime 00:00:01.964 ---