我正在尝试压缩一些数据库文件,以防升级过程中出现问题。数据库已停止,因此没有套接字:
# systemctl stop rh-mariadb102-mariadb.service
#
当我tar
在感兴趣的目录上运行时,它失败并显示:
# tar -cvfz mysql.tar.gz mysql/
...
mysql/ibdata1
mysql/aria_log_control
tar: Exiting with failure status due to previous errors
输出没有显示任何错误。我以 root 身份运行并且可以访问这些文件。例如:
# ls -Al mysql/aria_log_control
-rw-rw---- 1 mysql mysql 52 Dec 21 13:35 mysql/aria_log_control
错误是什么?如何修复?
手册tar(1)
页很简短,但以下是它提供的示例:
TAR(1) User Commands
NAME
tar - manual page for tar 1.26
SYNOPSIS
tar [OPTION...] [FILE]...
DESCRIPTION
GNU `tar' saves many files together into a single tape or disk archive,
and can restore individual files from the archive.
...
EXAMPLES
tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.
tar -tvf archive.tar
# List all files in archive.tar verbosely.
tar -xf archive.tar
# Extract all files from archive.tar.
这是该命令的完整输出。
# tar -cvfz mysql.tar.gz mysql/
tar: mysql.tar.gz: Cannot stat: No such file or directory
mysql/
mysql/ib_logfile0
mysql/mysql/
mysql/mysql/host.MYI
mysql/mysql/ndb_binlog_index.frm
mysql/mysql/general_log.CSV
mysql/mysql/columns_priv.MYD
mysql/mysql/help_keyword.MYI
mysql/mysql/user.MYD
mysql/mysql/help_category.frm
mysql/mysql/time_zone_transition_type.MYD
mysql/mysql/time_zone_transition.MYI
mysql/mysql/time_zone_name.MYD
mysql/mysql/db.MYD
mysql/mysql/time_zone_transition.MYD
mysql/mysql/time_zone_transition_type.MYI
mysql/mysql/plugin.frm
mysql/mysql/proxies_priv.MYI
mysql/mysql/help_relation.MYI
mysql/mysql/procs_priv.frm
mysql/mysql/user.frm
mysql/mysql/slow_log.frm
mysql/mysql/slow_log.CSV
mysql/mysql/help_topic.frm
mysql/mysql/db.MYI
mysql/mysql/host.MYD
mysql/mysql/help_category.MYD
mysql/mysql/time_zone.MYD
mysql/mysql/time_zone_name.frm
mysql/mysql/procs_priv.MYD
mysql/mysql/time_zone_leap_second.MYD
mysql/mysql/help_category.MYI
mysql/mysql/help_topic.MYD
mysql/mysql/time_zone.MYI
mysql/mysql/event.MYI
mysql/mysql/time_zone_transition.frm
mysql/mysql/plugin.MYD
mysql/mysql/time_zone.frm
mysql/mysql/time_zone_leap_second.frm
mysql/mysql/time_zone_transition_type.frm
mysql/mysql/plugin.MYI
mysql/mysql/procs_priv.MYI
mysql/mysql/proxies_priv.frm
mysql/mysql/proc.MYI
mysql/mysql/time_zone_name.MYI
mysql/mysql/tables_priv.MYD
mysql/mysql/user.MYI
mysql/mysql/help_relation.MYD
mysql/mysql/event.MYD
mysql/mysql/host.frm
mysql/mysql/ndb_binlog_index.MYD
mysql/mysql/time_zone_leap_second.MYI
mysql/mysql/servers.MYD
mysql/mysql/general_log.CSM
mysql/mysql/servers.frm
mysql/mysql/db.frm
mysql/mysql/func.MYD
mysql/mysql/slow_log.CSM
mysql/mysql/help_topic.MYI
mysql/mysql/proxies_priv.MYD
mysql/mysql/proc.frm
mysql/mysql/tables_priv.frm
mysql/mysql/ndb_binlog_index.MYI
mysql/mysql/func.MYI
mysql/mysql/columns_priv.frm
mysql/mysql/general_log.frm
mysql/mysql/columns_priv.MYI
mysql/mysql/tables_priv.MYI
mysql/mysql/func.frm
mysql/mysql/help_keyword.MYD
mysql/mysql/servers.MYI
mysql/mysql/help_relation.frm
mysql/mysql/help_keyword.frm
mysql/mysql/event.frm
mysql/mysql/proc.MYD
mysql/my_wiki/
mysql/my_wiki/wikicryptopp_uploadstash.MYI
mysql/my_wiki/wikilounge_objectcache.MYI
mysql/my_wiki/wikilounge_user_groups.MYD
mysql/my_wiki/wikicryptopp_revision.frm
mysql/my_wiki/wikicryptopp_page_props.frm
mysql/my_wiki/wikilounge_watchlist.frm
mysql/my_wiki/wikilounge_math.MYI
mysql/my_wiki/wikilounge_langlinks.MYD
mysql/my_wiki/wikicryptopp_archive.MYD
mysql/my_wiki/wikilounge_imagelinks.MYI
mysql/my_wiki/wikicryptopp_msg_resource.MYI
mysql/my_wiki/wikilounge_smw_specialprops.MYI
mysql/my_wiki/wikilounge_imagelinks.MYD
mysql/my_wiki/wikicryptopp_sites.MYD
mysql/my_wiki/wikilounge_site_stats.MYI
mysql/my_wiki/wikilounge_templatelinks.MYD
mysql/my_wiki/wikicryptopp_site_identifiers.frm
mysql/my_wiki/wikicryptopp_watchlist.MYI
mysql/my_wiki/wikicryptopp_searchindex.frm
mysql/my_wiki/wikilounge_revision.MYD
mysql/my_wiki/wikicryptopp_site_stats.MYI
mysql/my_wiki/wikicryptopp_text.MYD
mysql/my_wiki/wikilounge_archive.MYI
mysql/my_wiki/wikicryptopp_recentchanges.MYD
mysql/my_wiki/wikicryptopp_image.frm
mysql/my_wiki/wikicryptopp_site_identifiers.MYD
mysql/my_wiki/wikicryptopp_iwlinks.frm
mysql/my_wiki/wikilounge_transcache.frm
mysql/my_wiki/wikicryptopp_user_former_groups.MYD
mysql/my_wiki/wikilounge_querycache_info.frm
mysql/my_wiki/wikicryptopp_trackbacks.frm
mysql/my_wiki/wikilounge_image.MYD
mysql/my_wiki/wikicryptopp_log_search.frm
mysql/my_wiki/wikicryptopp_objectcache.frm
mysql/my_wiki/wikilounge_langlinks.frm
mysql/my_wiki/wikicryptopp_sites.MYI
mysql/my_wiki/wikicryptopp_pagelinks.MYD
mysql/my_wiki/wikilounge_pagelinks.frm
mysql/my_wiki/wikicryptopp_module_deps.MYD
mysql/my_wiki/wikicryptopp_category.frm
mysql/my_wiki/wikicryptopp_site_stats.frm
mysql/my_wiki/wikicryptopp_templatelinks.MYI
mysql/my_wiki/wikicryptopp_transcache.MYD
mysql/my_wiki/wikicryptopp_searchindex.MYI
mysql/my_wiki/wikilounge_filearchive.frm
mysql/my_wiki/wikicryptopp_text.frm
mysql/my_wiki/wikilounge_smw_attributes.MYD
mysql/my_wiki/wikicryptopp_querycache.MYD
mysql/my_wiki/wikilounge_trackbacks.MYI
mysql/my_wiki/wikicryptopp_user_newtalk.MYD
mysql/my_wiki/wikilounge_objectcache.MYD
mysql/my_wiki/wikilounge_site_stats.MYD
mysql/my_wiki/wikilounge_categorylinks.MYD
mysql/my_wiki/wikicryptopp_watchlist.frm
mysql/my_wiki/wikicryptopp_iwlinks.MYI
mysql/my_wiki/wikilounge_text.MYD
mysql/my_wiki/wikicryptopp_job.MYD
mysql/my_wiki/wikilounge_logging.frm
mysql/my_wiki/wikicryptopp_revision.MYD
mysql/my_wiki/wikilounge_searchindex.MYD
mysql/my_wiki/wikicryptopp_categorylinks.MYI
mysql/my_wiki/wikilounge_revision.MYI
mysql/my_wiki/wikilounge_langlinks.MYI
mysql/my_wiki/wikicryptopp_user.MYI
mysql/my_wiki/wikicryptopp_querycache_info.frm
mysql/my_wiki/wikilounge_imagelinks.frm
mysql/my_wiki/wikicryptopp_page.MYD
mysql/my_wiki/wikicryptopp_trackbacks.MYI
mysql/my_wiki/wikicryptopp_ipblocks.MYI
mysql/my_wiki/wikicryptopp_page.frm
mysql/my_wiki/wikilounge_text.frm
mysql/my_wiki/wikilounge_job.MYD
mysql/my_wiki/wikicryptopp_user_former_groups.frm
mysql/my_wiki/wikilounge_categorylinks.MYI
mysql/my_wiki/wikicryptopp_interwiki.MYD
mysql/my_wiki/wikicryptopp_valid_tag.frm
mysql/my_wiki/wikicryptopp_protected_titles.frm
mysql/my_wiki/wikicryptopp_site_stats.MYD
mysql/my_wiki/wikicryptopp_interwiki.MYI
mysql/my_wiki/wikicryptopp_uploadstash.MYD
mysql/my_wiki/wikilounge_categorylinks.frm
mysql/my_wiki/wikilounge_ipblocks.frm
mysql/my_wiki/wikicryptopp_iwlinks.MYD
mysql/my_wiki/db.opt
mysql/my_wiki/wikilounge_user_newtalk.MYI
mysql/my_wiki/wikicryptopp_module_deps.frm
mysql/my_wiki/wikicryptopp_user.frm
mysql/my_wiki/wikilounge_smw_specialprops.frm
mysql/my_wiki/wikilounge_image.frm
mysql/my_wiki/wikicryptopp_math.MYI
mysql/my_wiki/wikilounge_trackbacks.frm
mysql/my_wiki/wikilounge_filearchive.MYI
mysql/my_wiki/wikicryptopp_archive.frm
mysql/my_wiki/wikilounge_watchlist.MYI
mysql/my_wiki/wikicryptopp_transcache.frm
mysql/my_wiki/wikicryptopp_ipblocks.frm
mysql/my_wiki/wikilounge_smw_relations.MYD
mysql/my_wiki/wikicryptopp_imagelinks.MYD
mysql/my_wiki/wikilounge_page.frm
mysql/my_wiki/wikilounge_transcache.MYI
mysql/my_wiki/wikilounge_templatelinks.frm
mysql/my_wiki/wikilounge_querycache_info.MYI
mysql/my_wiki/wikilounge_oldimage.MYD
mysql/my_wiki/wikilounge_recentchanges.MYD
mysql/my_wiki/wikilounge_archive.frm
mysql/my_wiki/wikilounge_recentchanges.MYI
mysql/my_wiki/wikicryptopp_user.MYD
mysql/my_wiki/wikicryptopp_user_newtalk.frm
mysql/my_wiki/wikilounge_interwiki.frm
mysql/my_wiki/wikicryptopp_change_tag.frm
mysql/my_wiki/wikicryptopp_site_identifiers.MYI
mysql/my_wiki/wikilounge_site_stats.frm
mysql/my_wiki/wikicryptopp_externallinks.frm
mysql/my_wiki/wikicryptopp_filearchive.frm
mysql/my_wiki/wikicryptopp_langlinks.frm
mysql/my_wiki/wikilounge_ipblocks.MYI
mysql/my_wiki/wikilounge_searchindex.frm
mysql/my_wiki/wikilounge_watchlist.MYD
mysql/my_wiki/wikicryptopp_objectcache.MYI
mysql/my_wiki/wikicryptopp_querycache.MYI
mysql/my_wiki/wikilounge_smw_specialprops.MYD
mysql/my_wiki/wikicryptopp_math.MYD
mysql/my_wiki/wikicryptopp_msg_resource.MYD
mysql/my_wiki/wikicryptopp_filearchive.MYI
mysql/my_wiki/wikicryptopp_image.MYI
mysql/my_wiki/wikicryptopp_module_deps.MYI
mysql/my_wiki/wikicryptopp_redirect.frm
mysql/my_wiki/wikilounge_job.frm
mysql/my_wiki/wikicryptopp_querycache.frm
mysql/my_wiki/wikicryptopp_msg_resource.frm
mysql/my_wiki/wikicryptopp_user_groups.MYI
mysql/my_wiki/wikilounge_smw_attributes.frm
mysql/my_wiki/wikicryptopp_categorylinks.MYD
mysql/my_wiki/wikilounge_interwiki.MYD
mysql/my_wiki/wikilounge_objectcache.frm
mysql/my_wiki/wikicryptopp_objectcache.MYD
mysql/my_wiki/wikilounge_logging.MYI
mysql/my_wiki/wikicryptopp_sites.frm
mysql/my_wiki/wikicryptopp_oldimage.MYI
mysql/my_wiki/wikicryptopp_querycachetwo.frm
mysql/my_wiki/wikicryptopp_langlinks.MYI
mysql/my_wiki/wikicryptopp_msg_resource_links.frm
mysql/my_wiki/wikicryptopp_templatelinks.MYD
mysql/my_wiki/wikicryptopp_filearchive.MYD
mysql/my_wiki/wikicryptopp_page_restrictions.frm
mysql/my_wiki/wikilounge_oldimage.frm
mysql/my_wiki/wikilounge_math.frm
mysql/my_wiki/wikilounge_querycache.MYI
mysql/my_wiki/wikilounge_page.MYI
mysql/my_wiki/wikicryptopp_logging.frm
mysql/my_wiki/wikilounge_user_groups.frm
mysql/my_wiki/wikicryptopp_user_groups.frm
mysql/my_wiki/wikilounge_smw_attributes.MYI
mysql/my_wiki/wikicryptopp_external_user.frm
mysql/my_wiki/wikicryptopp_user_groups.MYD
mysql/my_wiki/wikicryptopp_externallinks.MYI
mysql/my_wiki/wikicryptopp_trackbacks.MYD
mysql/my_wiki/wikilounge_interwiki.MYI
mysql/my_wiki/wikilounge_pagelinks.MYI
mysql/my_wiki/wikilounge_revision.frm
mysql/my_wiki/wikicryptopp_user_former_groups.MYI
mysql/my_wiki/wikicryptopp_msg_resource_links.MYD
mysql/my_wiki/wikilounge_user.MYD
mysql/my_wiki/wikilounge_image.MYI
mysql/my_wiki/wikilounge_transcache.MYD
mysql/my_wiki/wikicryptopp_querycache_info.MYI
mysql/my_wiki/wikilounge_recentchanges.frm
mysql/my_wiki/wikicryptopp_imagelinks.MYI
mysql/my_wiki/wikilounge_user_newtalk.frm
mysql/my_wiki/wikicryptopp_pagelinks.frm
mysql/my_wiki/wikicryptopp_imagelinks.frm
mysql/my_wiki/wikicryptopp_transcache.MYI
mysql/my_wiki/wikicryptopp_job.frm
mysql/my_wiki/wikilounge_externallinks.MYI
mysql/my_wiki/wikilounge_querycache.MYD
mysql/my_wiki/wikicryptopp_msg_resource_links.MYI
mysql/my_wiki/wikicryptopp_interwiki.frm
mysql/my_wiki/wikicryptopp_templatelinks.frm
mysql/my_wiki/wikilounge_text.MYI
mysql/my_wiki/wikicryptopp_revision.MYI
mysql/my_wiki/wikicryptopp_querycache_info.MYD
mysql/my_wiki/wikicryptopp_math.frm
mysql/my_wiki/wikicryptopp_updatelog.frm
mysql/my_wiki/wikilounge_smw_relations.MYI
mysql/my_wiki/wikilounge_pagelinks.MYD
mysql/my_wiki/wikilounge_trackbacks.MYD
mysql/my_wiki/wikicryptopp_externallinks.MYD
mysql/my_wiki/wikicryptopp_uploadstash.frm
mysql/my_wiki/wikilounge_user_newtalk.MYD
mysql/my_wiki/wikicryptopp_job.MYI
mysql/my_wiki/wikicryptopp_user_newtalk.MYI
mysql/my_wiki/wikicryptopp_page.MYI
mysql/my_wiki/wikilounge_filearchive.MYD
mysql/my_wiki/wikilounge_user.frm
mysql/my_wiki/wikicryptopp_oldimage.MYD
mysql/my_wiki/wikicryptopp_text.MYI
mysql/my_wiki/wikicryptopp_categorylinks.frm
mysql/my_wiki/wikilounge_externallinks.frm
mysql/my_wiki/wikilounge_smw_relations.frm
mysql/my_wiki/wikilounge_user_groups.MYI
mysql/my_wiki/wikilounge_querycache_info.MYD
mysql/my_wiki/wikicryptopp_pagelinks.MYI
mysql/my_wiki/wikilounge_archive.MYD
mysql/my_wiki/wikicryptopp_searchindex.MYD
mysql/my_wiki/wikilounge_hitcounter.frm
mysql/my_wiki/wikicryptopp_langlinks.MYD
mysql/my_wiki/wikicryptopp_watchlist.MYD
mysql/my_wiki/wikilounge_querycache.frm
mysql/my_wiki/wikicryptopp_recentchanges.MYI
mysql/my_wiki/wikilounge_searchindex.MYI
mysql/my_wiki/wikicryptopp_tag_summary.frm
mysql/my_wiki/wikicryptopp_l10n_cache.frm
mysql/my_wiki/wikilounge_job.MYI
mysql/my_wiki/wikilounge_user.MYI
mysql/my_wiki/wikilounge_page.MYD
mysql/my_wiki/wikicryptopp_user_properties.frm
mysql/my_wiki/wikilounge_templatelinks.MYI
mysql/my_wiki/wikilounge_externallinks.MYD
mysql/my_wiki/wikilounge_logging.MYD
mysql/my_wiki/wikilounge_math.MYD
mysql/my_wiki/wikilounge_ipblocks.MYD
mysql/my_wiki/wikilounge_oldimage.MYI
mysql/my_wiki/wikicryptopp_logging.MYI
mysql/my_wiki/wikicryptopp_ipblocks.MYD
mysql/my_wiki/wikicryptopp_archive.MYI
mysql/my_wiki/wikicryptopp_logging.MYD
mysql/my_wiki/wikicryptopp_oldimage.frm
mysql/my_wiki/wikicryptopp_image.MYD
mysql/my_wiki/wikicryptopp_recentchanges.frm
mysql/performance_schema/
mysql/performance_schema/file_summary_by_event_name.frm
mysql/performance_schema/cond_instances.frm
mysql/performance_schema/setup_consumers.frm
mysql/performance_schema/events_waits_summary_global_by_event_name.frm
mysql/performance_schema/mutex_instances.frm
mysql/performance_schema/setup_timers.frm
mysql/performance_schema/db.opt
mysql/performance_schema/events_waits_current.frm
mysql/performance_schema/events_waits_history.frm
mysql/performance_schema/performance_timers.frm
mysql/performance_schema/threads.frm
mysql/performance_schema/file_summary_by_instance.frm
mysql/performance_schema/events_waits_summary_by_thread_by_event_name.frm
mysql/performance_schema/setup_instruments.frm
mysql/performance_schema/file_instances.frm
mysql/performance_schema/rwlock_instances.frm
mysql/performance_schema/events_waits_history_long.frm
mysql/performance_schema/events_waits_summary_by_instance.frm
mysql/aria_log.00000001
mysql/ib_logfile1
mysql/ibdata1
mysql/aria_log_control
tar: Exiting with failure status due to previous errors
#
答案1
你把f
开关放错地方了。它应该是tar -cvzf
。如果省略破折号,tar cvfz
就可以了。手册页中提到了这一点:
任意数量的不带参数的选项可以在一个破折号后聚集在一起,例如 -vkp。带参数的选项(无论是强制的还是可选的)可以出现在此类簇的末尾,例如-vkpf a.tar。
答案2
这种编写 tar 选项的旧方法甚至会让经验丰富的用户感到惊讶。例如两条命令:
tar cfz archive.tar.gz file
tar -cfz archive.tar.gz file
是完全不同的。第一个示例使用
archive.tar.gz' as the value for option
f' 并将选项z'. The second example, however, uses
z' 识别为选项“f”的值——可能不是预期的结果。第二个示例可以通过多种方式进行纠正,其中以下是等效的:
tar -czf archive.tar.gz file
tar -cf archive.tar.gz -z file
tar cf archive.tar.gz -z file
答案3
tar -cvfz mysql.tar.gz mysql/
tar:mysql.tar.gz:无法统计:没有这样的文件或目录
该错误意味着tar
无法找到 mysql.tar.gz 添加到存档中。
(-)f
后面应该跟文件名,在这种情况下,您的命令尝试创建一个名为z
&mysql.tar.gz
的存档mysql/
。
一般来说,大多数标志的顺序并不重要,但对于指定要创建的文件名来说却很重要。
如果你使用tar -cvzf mysql.tar.gz mysql/
它应该可以工作
答案4
为了直接回答您实际提出的问题,它所指的错误当然是这个,位于输出的第一行:
tar: mysql.tar.gz: Cannot stat: No such file or directory
也就是说,该名称的文件被列出来存储在存档中,因此这就是它试图执行的操作。它假设您无论如何都希望将其余文件存档,并且在任何情况下都无法知道您希望丢失的文件成为致命错误。